Skip to content

Checksuit

Checksuit #1775

Workflow file for this run

name: Checksuit
on:
workflow_run:
workflows:
- Monorepo pipeline - build and deploy
types:
- completed
branches:
- main
pull_request:
types:
- opened
- synchronize
- labeled
permissions:
contents: write
pull-requests: write
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
detect-failure:
name: Determine Failure
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
outputs:
PR_NUMBER: ${{ steps.fetch-pr.outputs.PR_NUMBER }}
steps:
- uses: actions/checkout@v4
- name: Debug
run: |
echo "Conclusion: ${{ github.event.workflow_run.conclusion }}"
- name: Fetch PR
id: fetch-pr
run: |
COMMIT_SHA="${{ github.event.workflow_run.head_commit.id }}"
if ! PR_NUMBER=$(bash ./scripts/ci/get-pr.sh "$COMMIT_SHA"); then
echo "Error: Failed to get PR number for commit $COMMIT_SHA"
exit 1
fi
if [ -n "$PR_NUMBER" ]; then
echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT
else
echo "No merged PR found for commit $COMMIT_SHA."
fi
- name: Add Revert Label
id: add-revert-label
if: ${{ steps.fetch-pr.outputs.PR_NUMBER && github.event.workflow_run.conclusion == 'failure' }}
run: |
PR_NUMBER="${{ steps.fetch-pr.outputs.PR_NUMBER }}"
if [ -z "$PR_NUMBER" ]; then
echo "Error: PR number is empty"
exit 1
fi
echo "Adding revert label to PR: $PR_NUMBER"
if ! gh pr edit "$PR_NUMBER" --add-label "revert"; then
echo "Error: Failed to add revert label"
exit 1
fi
create-revert-pr:
name: Automated PR revert
needs: detect-failure
if: ${{ needs.detect-failure.outputs.PR_NUMBER && github.event.workflow_run.conclusion == 'failure' }}
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
steps:
- name: Debug
run: |
PR_NUMBER=${{ needs.detect-failure.outputs.PR_NUMBER }}
echo "Reverting PR: $PR_NUMBER"
- name: Execute PR revert
if: ${{ vars.ENABLE_PR_REVERT == 'true' }}
run: |
REVERT_PR=$(bash ./scripts/ci/revert-pr.sh "$PR_NUMBER")
gh pr edit $REVERT_PR --add-label "automerge,high priority"
manual-revert-pr:
name: Manual PR revert
runs-on: ec2-runners
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'revert') && (github.event.pull_request.merged == true || github.event.pull_request.draft == true) && github.actor != 'github-actions' }}
steps:
- name: Debug
run: |
echo "actor: ${{ github.actor }}"
echo "Reverting PR: ${{ github.event.pull_request.number }}"
- name: Execute PR revert
if: ${{ vars.ENABLE_PR_REVERT == 'true' }}
run: |
REVERT_PR=$(bash ./scripts/ci/revert-pr.sh "${{ github.event.pull_request.number }}")
gh pr edit $REVERT_PR --add-label "automerge,high priority"