Files
Joey Parrish 7dbdb372e4 ci: Update workflow permissions (#7731)
Now that default permissions are read-only, we must enable specific permissions for certain workflow jobs.

This fixes every job except "update screenshots", which has unresolved permissions issues.
2024-12-09 20:39:34 -08:00

36 lines
1.2 KiB
YAML

name: Deflake Tests
# Runs when the Selenum lab test or PR test workflows complete. This will run
# with full privileges, even if the other workflow doesn't. That allows us to
# trigger re-runs if we think the results might be flaky. A test run will be
# given up to 3 runs to succeed.
on:
workflow_run:
workflows:
- Selenium Lab Tests
- Build and Test
types: [completed]
jobs:
deflake:
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ubuntu-latest
permissions:
# "Write" to Actions to enable rerun command.
actions: write
steps:
- name: Check run count and re-run workflow
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api /repos/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }} > run.json
RUNS=$(jq -r .run_attempt < run.json)
if [[ "$RUNS" -lt 3 ]]; then
echo "$RUNS failed runs so far; re-running workflow."
gh run rerun ${{ github.event.workflow_run.id }} --failed -R ${{ github.repository }}
else
echo "$RUNS failed runs so far; not re-running workflow."
fi