-
Notifications
You must be signed in to change notification settings - Fork 4
134 lines (128 loc) · 3.6 KB
/
queue_commits.yml
File metadata and controls
134 lines (128 loc) · 3.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Queue Commits From Bevy Main
on:
workflow_dispatch:
schedule:
- cron: "0 * * * *"
jobs:
queue-latest-commit:
name: Queue Latest Commit
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: "bevyengine/bevy"
ref: "main"
- uses: actions/checkout@v4
with:
ref: "queue"
path: "queue"
- uses: actions/checkout@v4
with:
ref: "results"
path: "results"
- name: Queue latest commit
id: queue
run: |
gitref=`git rev-parse HEAD`
if ls queue/$gitref 1> /dev/null 2>&1
then
echo "commit already queued"
echo "ADDED=0" >> "$GITHUB_OUTPUT"
exit 0
fi
if find results/ | grep $gitref 1> /dev/null 2>&1
then
echo "commit already collected"
echo "ADDED=0" >> "$GITHUB_OUTPUT"
exit 0
fi
cd queue
touch $gitref
echo "ADDED=1" >> "$GITHUB_OUTPUT"
- name: Commit
if: steps.queue.outputs.ADDED > 0
run: |
cd queue
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Queued new commit"
git push
check-queue:
name: Check Queue
runs-on: ubuntu-latest
needs: [queue-latest-commit]
outputs:
queue_is_empty: ${{ steps.check_queue.outputs.QUEUE_IS_EMPTY }}
steps:
- uses: actions/checkout@v4
with:
ref: "queue"
- name: Check if queue is empty
id: check_queue
run: |
if [ `ls -1 | wc -l` -eq 0 ]; then
echo "Queue is empty"
echo "QUEUE_IS_EMPTY=true" >> "$GITHUB_OUTPUT"
else
echo "Queue is not empty"
echo "QUEUE_IS_EMPTY=false" >> "$GITHUB_OUTPUT"
fi
queue-history-commits:
needs: [check-queue]
if: needs.check-queue.outputs.queue_is_empty == 'true'
name: Queue History Commits
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout Bevy main branch
uses: actions/checkout@v4
with:
repository: "bevyengine/bevy"
ref: "main"
path: "bevy"
fetch-depth: 500
- uses: actions/checkout@v4
with:
ref: "queue"
path: "queue"
- uses: actions/checkout@v4
with:
ref: "results"
path: "results"
- name: Queue history commits
id: queue
run: |
cd bevy
i=0
j=0
max=3
for commit in `git log --no-abbrev-commit --pretty=oneline | sort | cut -d ' ' -f 1`
do
if find ../results/ | grep $commit 1> /dev/null 2>&1
then
:
else
j=$((j + 1))
if [ $i -lt $max ]; then
i=$((i + 1))
touch ../queue/$commit
fi
fi
done
echo "Added $i commits out of $j missing commits"
echo "ADDED=$i" >> "$GITHUB_OUTPUT"
echo "TOTAL=$j" >> "$GITHUB_OUTPUT"
- name: Commit
if: steps.queue.outputs.ADDED > 0
run: |
cd queue
git config user.name 'Workflow'
git config user.email '<>'
git add .
git commit -m "Queued ${{ steps.queue.outputs.ADDED }} / ${{ steps.queue.outputs.TOTAL }} history commits"
git push