Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: auto revert PRs when they break main #17061

Merged
merged 31 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
eaeb0b5
ci: auto revert PRs when they break main
busla Nov 28, 2024
0bcbeb2
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
e6f977a
chore: debug
busla Nov 28, 2024
a4f3353
Merge branch 'ci/revert-pr-workflow' of github.com:island-is/island.i…
busla Nov 28, 2024
456e7aa
chore: debug
busla Nov 28, 2024
e512d65
chore: debug
busla Nov 28, 2024
9470d9b
fix: reviewdog
busla Nov 28, 2024
a2694db
fix: webhook
busla Nov 28, 2024
b658dec
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
93827a4
fix: improvements
busla Nov 28, 2024
44dbea3
Merge branch 'ci/revert-pr-workflow' of github.com:island-is/island.i…
busla Nov 28, 2024
896940b
chore: draft
busla Nov 28, 2024
873921b
fix: needs
busla Nov 28, 2024
b109bc7
fix: use separate labels for manual and auto revert
busla Nov 28, 2024
ab9eec4
fix: check actor
busla Nov 28, 2024
340f481
chore: debug
busla Nov 28, 2024
6c02074
chore: debug
busla Nov 28, 2024
e71ba87
fix: enable revert on vars toggle
busla Nov 28, 2024
0997f12
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
d1b6677
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
1fc93e2
Update .github/workflows/revert-pr.yaml
busla Nov 28, 2024
3900c27
fix: typo
busla Nov 28, 2024
d07330a
fix: typo
busla Nov 28, 2024
296bce7
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
fd0dd51
fix: cleanup
busla Nov 28, 2024
1491be0
Merge branch 'ci/revert-pr-workflow' of github.com:island-is/island.i…
busla Nov 28, 2024
69c3943
Update .github/workflows/revert-pr.yaml
busla Nov 28, 2024
459b1f8
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
529a85b
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
1fc5c39
Merge branch 'main' into ci/revert-pr-workflow
busla Nov 28, 2024
eb745c1
Merge branch 'main' into ci/revert-pr-workflow
kodiakhq[bot] Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/pullrequest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ jobs:
with:
github_token: ${{ secrets.github_token }}
reporter: github-pr-review
fail_on_error: true
level: info
fail-level: info
busla marked this conversation as resolved.
Show resolved Hide resolved
exclude: >-
*/node_modules/*

Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/revert-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Auto Revert on Failed Checks

on:
check_suite:
types: [completed]

permissions:
contents: write
pull-requests: write

jobs:
auto-revert:
name: Revert PR
runs-on: ec2-runners
busla marked this conversation as resolved.
Show resolved Hide resolved
container:
image: public.ecr.aws/m3u4c4h9/island-is/actions-runner-public:latest
# if: github.event.pull_request.merged == true && github.event.workflow_run.conclusion == 'failure'
steps:
- uses: actions/checkout@v4

- name: Debug
run: |
echo '${{ toJson(github.event.check_suit.conclusion) }}'
- name: Create Revert PR
if: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo ${{ github.event.workflow_run.conclusion }}
REVERT_PR=$(bash ./scripts/ci/revert-pr.sh "${{ github.event.pull_request.number }}")
gh pr edit $REVERT_PR --add-label "automerge,high priority"
23 changes: 23 additions & 0 deletions scripts/ci/revert-pr.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

PR=$1
busla marked this conversation as resolved.
Show resolved Hide resolved
read -r NODE_ID TITLE < <(gh api "repos/island-is/island.is/pulls/${PR}" --jq '[.node_id, .title] | @tsv')
busla marked this conversation as resolved.
Show resolved Hide resolved

# shellcheck disable=SC2016
gh api graphql -f query='
mutation ($pr: ID!, $title: String, $body: String) {
revertPullRequest(
input: {
title: $title,
body: $body,
pullRequestId: $pr
}
) {
revertPullRequest {
number
}
}
}' \
-f "pr=${NODE_ID}" \
-f "title=revert: ⚠️ ${TITLE}" \
-f "body=Reverts PR #${PR}" --jq '.data.revertPullRequest.revertPullRequest.number'
busla marked this conversation as resolved.
Show resolved Hide resolved
Loading