refactor: allow setting max retries for restarting analyzer #36
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Adds labels | |
| on: | |
| pull_request_target: | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: "Pull Request number to check" | |
| required: true | |
| type: number | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| pull-requests: write | |
| timeout-minutes: 60 | |
| env: | |
| GH_TOKEN: ${{ github.token }} | |
| PR_NUMBER: ${{ github.event.inputs.pr_number || github.event.number }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Check rebase/merge | |
| run: | | |
| echo "Checking if PR is behind the base branch..." | |
| MERGEABLE=$(gh pr view $PR_NUMBER --json mergeable | jq -r .mergeable) | |
| echo "MERGEABLE: $MERGEABLE" | |
| if [[ $MERGEABLE != 'MERGEABLE' ]]; then | |
| echo "Branch is behind. Labeling as needs rebase." | |
| gh pr edit $PR_NUMBER --add-label "S-needs-rebase" | |
| else | |
| echo "Branch is up to date." | |
| gh pr edit $PR_NUMBER --remove-label "S-needs-rebase" | |
| fi | |
| - name: Check CI | |
| run: | | |
| # Give some breathing room at the start. | |
| sleep 30 | |
| echo "Waiting for CI pipelines to start" | |
| result="" | |
| # Wait for more than one pipeline to spawn. | |
| until [[ $result -gt 1 ]]; do | |
| result=$( | |
| gh pr checks $PR_NUMBER \ | |
| --json "bucket" \ | |
| --jq "[.[] | select(.bucket == \"pending\")] | length" | |
| ) | |
| sleep 15 | |
| done | |
| # Wait for only the add labels pipeline to be remaining. | |
| echo "Waiting while CI pipelines complete" | |
| until [[ $result -eq 1 ]]; do | |
| result=$( | |
| gh pr checks $PR_NUMBER \ | |
| --json "bucket" \ | |
| --jq "[.[] | select(.bucket == \"pending\")] | length" | |
| ) | |
| sleep 15 | |
| done | |
| echo "Evaluating whether there were any CI failures" | |
| result=$( | |
| gh pr checks $PR_NUMBER \ | |
| --json "bucket" \ | |
| --jq "isempty(.[] | select(.bucket == \"fail\"))" | |
| ) | |
| if [[ $result == "true" ]]; then | |
| gh pr edit $PR_NUMBER --remove-label "S-awaiting-CI" | |
| else | |
| gh pr edit $PR_NUMBER --add-label "S-awaiting-CI" | |
| fi | |
| echo "Finished!" |