Skip to content

Commit 42723e4

Browse files
authored
Merge pull request #18 from gitgitgadget-workflows/work-around-403s
Work around 403s when synchronizing the mailing list mirror
2 parents 9ea769e + d41c899 commit 42723e4

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

.github/workflows/sync-mailing-list-mirror.yml

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ jobs:
2626
set -x
2727
echo "org=${TARGET_GITHUB_REPOSITORY%%/*}" >>$GITHUB_OUTPUT &&
2828
echo "repo=${TARGET_GITHUB_REPOSITORY#*/}" >>$GITHUB_OUTPUT &&
29+
test workflow_dispatch != '${{ github.event_name }}' || {
30+
echo "result=true" >>$GITHUB_OUTPUT
31+
exit 0
32+
}
2933
source="$(git ls-remote "$SOURCE_REPOSITORY" master)" &&
3034
target="$(git ls-remote https://github.com/"$TARGET_GITHUB_REPOSITORY" lore-$LORE_EPOCH)" &&
3135
echo "result=$(test "${source%% *}" = "${target%% *}" && echo false || echo true)" >>$GITHUB_OUTPUT
@@ -51,4 +55,19 @@ jobs:
5155
env:
5256
GITHUB_TOKEN: ${{ steps.token.outputs.token }}
5357
run: |
54-
git push https://$GITHUB_ACTOR:[email protected]/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH
58+
backoff=0
59+
while (
60+
git push https://$GITHUB_ACTOR:[email protected]/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH;
61+
echo $? >exit.code
62+
) 2>&1 | tee output.log; exit_code="$(cat exit.code)"; test 0 != "$exit_code" && grep 403 output.log
63+
do
64+
backoff=$(($backoff+1))
65+
test 10 -gt $backoff || {
66+
echo '::error::Failed too many times' >&2
67+
exit $exit_code
68+
}
69+
printf '::warning::access token somehow not yet active; sleeping for %d seconds\nexit code: %s\n' \
70+
$backoff $(cat exit.code)
71+
sleep $backoff
72+
done
73+
exit $exit_code

0 commit comments

Comments
 (0)