diff --git a/.github/workflows/sync-mailing-list-mirror.yml b/.github/workflows/sync-mailing-list-mirror.yml index b08b856..618d154 100644 --- a/.github/workflows/sync-mailing-list-mirror.yml +++ b/.github/workflows/sync-mailing-list-mirror.yml @@ -26,6 +26,10 @@ jobs: set -x echo "org=${TARGET_GITHUB_REPOSITORY%%/*}" >>$GITHUB_OUTPUT && echo "repo=${TARGET_GITHUB_REPOSITORY#*/}" >>$GITHUB_OUTPUT && + test workflow_dispatch != '${{ github.event_name }}' || { + echo "result=true" >>$GITHUB_OUTPUT + exit 0 + } source="$(git ls-remote "$SOURCE_REPOSITORY" master)" && target="$(git ls-remote https://github.com/"$TARGET_GITHUB_REPOSITORY" lore-$LORE_EPOCH)" && echo "result=$(test "${source%% *}" = "${target%% *}" && echo false || echo true)" >>$GITHUB_OUTPUT @@ -51,4 +55,19 @@ jobs: env: GITHUB_TOKEN: ${{ steps.token.outputs.token }} run: | - git push https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH + backoff=0 + while ( + git push https://$GITHUB_ACTOR:$GITHUB_TOKEN@github.com/$TARGET_GITHUB_REPOSITORY lore-$LORE_EPOCH; + echo $? >exit.code + ) 2>&1 | tee output.log; exit_code="$(cat exit.code)"; test 0 != "$exit_code" && grep 403 output.log + do + backoff=$(($backoff+1)) + test 10 -gt $backoff || { + echo '::error::Failed too many times' >&2 + exit $exit_code + } + printf '::warning::access token somehow not yet active; sleeping for %d seconds\nexit code: %s\n' \ + $backoff $(cat exit.code) + sleep $backoff + done + exit $exit_code