Skip to content

Commit e7cb45c

Browse files
committed
Refactor workflows: standardize commit step with retry logic
- Add push retry logic (max 3 attempts) across all data update workflows - Standardize git config to use "github-actions" user/email - Add fetch/checkout/pull-rebase sequence before operations - Use explicit file adds instead of wildcards - Maintain consistent error handling and exit codes Signed-off-by: Igor Pecovnik <igor@armbian.com>
1 parent ba36e7b commit e7cb45c

14 files changed

Lines changed: 371 additions & 98 deletions

.github/workflows/data-update-base-files-info.yml

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,40 @@ jobs:
4040
# Step 5: Commit changes if any
4141
- name: Commit changes if any
4242
run: |
43+
set -euo pipefail
44+
45+
git config user.name "github-actions"
46+
git config user.email "github-actions@github.com"
47+
48+
git fetch origin data
4349
git checkout data
44-
mkdir -p data/
50+
git pull --rebase origin data
51+
52+
mkdir -p data
4553
mv base-files.json data/base-files.json
46-
git config user.name "github-actions[bot]"
47-
git config user.email "github-actions[bot]@users.noreply.github.com"
54+
4855
git add data/base-files.json
49-
git diff --cached --quiet || git commit -m "Update base-files package info"
50-
git push
56+
if ! git diff --cached --quiet; then
57+
git commit -m "Update base-files package info"
58+
# Push with retry logic
59+
max_attempts=3
60+
attempt=1
61+
while [ $attempt -le $max_attempts ]; do
62+
if git push origin data; then
63+
echo "Successfully pushed to data branch"
64+
exit 0
65+
fi
66+
67+
# Pull with rebase to resolve conflicts
68+
echo "Push failed, attempting to pull and rebase..." >&2
69+
git pull --rebase origin data
70+
71+
attempt=$((attempt + 1))
72+
done
73+
74+
echo "Failed to push after $max_attempts attempts" >&2
75+
exit 1
76+
fi
5177
5278
- name: "Generate directory"
5379
uses: peter-evans/repository-dispatch@v4

.github/workflows/data-update-download-index.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,24 @@ jobs:
123123
git add data/armbian-images.json data/all-torrents.zip
124124
if ! git diff --cached --quiet; then
125125
git commit -m "Update armbian-images.json and all-torrents.zip"
126-
# rebase once more right before push to reduce race window
127-
git pull --rebase origin data
128-
git push origin data
126+
# Push with retry logic
127+
max_attempts=3
128+
attempt=1
129+
while [ $attempt -le $max_attempts ]; do
130+
if git push origin data; then
131+
echo "Successfully pushed to data branch"
132+
exit 0
133+
fi
134+
135+
# Pull with rebase to resolve conflicts
136+
echo "Push failed, attempting to pull and rebase..." >&2
137+
git pull --rebase origin data
138+
139+
attempt=$((attempt + 1))
140+
done
141+
142+
echo "Failed to push after $max_attempts attempts" >&2
143+
exit 1
129144
fi
130145
131146
- name: "Generate directory"

.github/workflows/data-update-image-info.yml

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,41 @@ jobs:
4848
./compile.sh inventory-boards
4949
5050
- name: Commit changes if any
51-
shell: bash
5251
run: |
53-
54-
cd armbian.github.io
5552
set -euo pipefail
53+
cd armbian.github.io
54+
55+
git config user.name "github-actions"
56+
git config user.email "github-actions@github.com"
57+
58+
git fetch origin data
5659
git checkout data
57-
mv ${{ github.workspace }}/build/output/info/image-info.json data/
60+
git pull --rebase origin data
5861
59-
git config --global user.name "github-actions"
60-
git config --global user.email "github-actions@github.com"
61-
git add data/image-info.json
62+
mkdir -p data
63+
mv "${{ github.workspace }}/build/output/info/image-info.json" data/
6264
65+
git add data/image-info.json
6366
if ! git diff --cached --quiet; then
6467
git commit -m "Update image-info.json from build repository"
65-
git push
66-
else
67-
echo "No changes to commit."
68+
# Push with retry logic
69+
max_attempts=3
70+
attempt=1
71+
while [ $attempt -le $max_attempts ]; do
72+
if git push origin data; then
73+
echo "Successfully pushed to data branch"
74+
exit 0
75+
fi
76+
77+
# Pull with rebase to resolve conflicts
78+
echo "Push failed, attempting to pull and rebase..." >&2
79+
git pull --rebase origin data
80+
81+
attempt=$((attempt + 1))
82+
done
83+
84+
echo "Failed to push after $max_attempts attempts" >&2
85+
exit 1
6886
fi
6987
7088
- name: "Run Bigin update action"

.github/workflows/data-update-jira-excerpt.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,18 +150,43 @@ jobs:
150150
PY
151151
152152
- name: Commit changes if any
153-
shell: bash
154153
run: |
154+
set -euo pipefail
155155
cd armbian.github.io
156-
git checkout data
157-
mkdir -p data/
158-
mv ${{ github.workspace }}/jira-current.html data/
159-
mv ${{ github.workspace }}/jira-next.html data/
156+
160157
git config user.name "github-actions"
161158
git config user.email "github-actions@github.com"
162-
git add data/.
163-
git diff --cached --quiet || git commit -m "Update WEB index files"
164-
git push
159+
160+
git fetch origin data
161+
git checkout data
162+
git pull --rebase origin data
163+
164+
mkdir -p data
165+
mv "${{ github.workspace }}/jira-current.html" data/
166+
mv "${{ github.workspace }}/jira-next.html" data/
167+
168+
git add data/jira-current.html data/jira-next.html
169+
if ! git diff --cached --quiet; then
170+
git commit -m "Update WEB index files"
171+
# Push with retry logic
172+
max_attempts=3
173+
attempt=1
174+
while [ $attempt -le $max_attempts ]; do
175+
if git push origin data; then
176+
echo "Successfully pushed to data branch"
177+
exit 0
178+
fi
179+
180+
# Pull with rebase to resolve conflicts
181+
echo "Push failed, attempting to pull and rebase..." >&2
182+
git pull --rebase origin data
183+
184+
attempt=$((attempt + 1))
185+
done
186+
187+
echo "Failed to push after $max_attempts attempts" >&2
188+
exit 1
189+
fi
165190
166191
- name: "Run pull from Repository action"
167192
uses: peter-evans/repository-dispatch@v4

.github/workflows/data-update-partners-data.yml

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,42 @@ jobs:
145145
146146
- name: Commit and push JSON files
147147
run: |
148-
148+
set -euo pipefail
149149
cd armbian.github.io
150+
151+
git config user.name "github-actions"
152+
git config user.email "github-actions@github.com"
153+
154+
git fetch origin data
150155
git checkout data
151-
mkdir -p data/
152-
cp ${{ github.workspace }}/partners.json data/
153-
cp ${{ github.workspace }}/maintainers.json data/
154-
git config user.name "github-actions[bot]"
155-
git config user.email "github-actions[bot]@users.noreply.github.com"
156+
git pull --rebase origin data
157+
158+
mkdir -p data
159+
cp "${{ github.workspace }}/partners.json" data/
160+
cp "${{ github.workspace }}/maintainers.json" data/
161+
156162
git add data/partners.json data/maintainers.json
157-
git commit -m "Update of Bigin sourced JSON files" || echo "No changes to commit"
158-
git push
163+
if ! git diff --cached --quiet; then
164+
git commit -m "Update of Bigin sourced JSON files"
165+
# Push with retry logic
166+
max_attempts=3
167+
attempt=1
168+
while [ $attempt -le $max_attempts ]; do
169+
if git push origin data; then
170+
echo "Successfully pushed to data branch"
171+
exit 0
172+
fi
173+
174+
# Pull with rebase to resolve conflicts
175+
echo "Push failed, attempting to pull and rebase..." >&2
176+
git pull --rebase origin data
177+
178+
attempt=$((attempt + 1))
179+
done
180+
181+
echo "Failed to push after $max_attempts attempts" >&2
182+
exit 1
183+
fi
159184
160185
- name: "Generate directory"
161186
uses: peter-evans/repository-dispatch@v4

.github/workflows/data-update-rpi-imager-json.yml

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,38 @@ jobs:
4545
4646
- name: Commit changes if any
4747
run: |
48-
48+
set -euo pipefail
4949
cd armbian.github.io
50-
git fetch origin data:remotes/origin/data || true
51-
git checkout data || git checkout -b data
52-
mkdir -p data/
5350
54-
cp ${{ github.workspace }}/rpi-imager.json data/
51+
git config user.name "github-actions"
52+
git config user.email "github-actions@github.com"
53+
54+
git fetch origin data
55+
git checkout data
56+
git pull --rebase origin data
57+
58+
mkdir -p data
59+
cp "${{ github.workspace }}/rpi-imager.json" data/
60+
61+
git add data/rpi-imager.json
62+
if ! git diff --cached --quiet; then
63+
git commit -m "Update WEB index files"
64+
# Push with retry logic
65+
max_attempts=3
66+
attempt=1
67+
while [ $attempt -le $max_attempts ]; do
68+
if git push origin data; then
69+
echo "Successfully pushed to data branch"
70+
exit 0
71+
fi
72+
73+
# Pull with rebase to resolve conflicts
74+
echo "Push failed, attempting to pull and rebase..." >&2
75+
git pull --rebase origin data
76+
77+
attempt=$((attempt + 1))
78+
done
5579
56-
git config user.name "github-actions[bot]"
57-
git config user.email "github-actions[bot]@users.noreply.github.com"
58-
git add data/.
59-
git diff --cached --quiet || git commit -m "Update WEB index files"
60-
git push origin data --force-with-lease
80+
echo "Failed to push after $max_attempts attempts" >&2
81+
exit 1
82+
fi

.github/workflows/generate-actions-report.yml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,37 @@ jobs:
118118
119119
- name: Commit to data branch
120120
run: |
121+
set -euo pipefail
121122
cd data-branch
122-
git config user.name "GitHub Actions"
123-
git config user.email "actions@github.com"
123+
124+
git config user.name "github-actions"
125+
git config user.email "github-actions@github.com"
126+
127+
git fetch origin data
128+
git checkout data
129+
git pull --rebase origin data
130+
124131
git add data/actions-report/
125-
if git diff --staged --quiet; then
126-
echo "No changes to commit"
127-
else
132+
if ! git diff --cached --quiet; then
128133
git commit -m "Update actions reports [skip ci]"
129-
git push
134+
# Push with retry logic
135+
max_attempts=3
136+
attempt=1
137+
while [ $attempt -le $max_attempts ]; do
138+
if git push origin data; then
139+
echo "Successfully pushed to data branch"
140+
exit 0
141+
fi
142+
143+
# Pull with rebase to resolve conflicts
144+
echo "Push failed, attempting to pull and rebase..." >&2
145+
git pull --rebase origin data
146+
147+
attempt=$((attempt + 1))
148+
done
149+
150+
echo "Failed to push after $max_attempts attempts" >&2
151+
exit 1
130152
fi
131153
132154
# Run website generation

.github/workflows/generate-build-lists.yaml

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,37 @@ jobs:
8686
8787
- name: Commit to data branch
8888
run: |
89+
set -euo pipefail
8990
cd data-branch
90-
git config user.name "GitHub Actions"
91-
git config user.email "actions@github.com"
91+
92+
git config user.name "github-actions"
93+
git config user.email "github-actions@github.com"
94+
95+
git fetch origin data
96+
git checkout data
97+
git pull --rebase origin data
98+
9299
git add data/release-targets/
93-
if git diff --staged --quiet; then
94-
echo "No changes to commit"
95-
else
100+
if ! git diff --cached --quiet; then
96101
git commit -m "Update release targets and kernel descriptions [skip ci]"
97-
git push
102+
# Push with retry logic
103+
max_attempts=3
104+
attempt=1
105+
while [ $attempt -le $max_attempts ]; do
106+
if git push origin data; then
107+
echo "Successfully pushed to data branch"
108+
exit 0
109+
fi
110+
111+
# Pull with rebase to resolve conflicts
112+
echo "Push failed, attempting to pull and rebase..." >&2
113+
git pull --rebase origin data
114+
115+
attempt=$((attempt + 1))
116+
done
117+
118+
echo "Failed to push after $max_attempts attempts" >&2
119+
exit 1
98120
fi
99121
100122
- name: "Generate directory"

0 commit comments

Comments
 (0)