mirror of
https://github.com/Sea-Haven-Industries/file-share.git
synced 2026-09-30 04:23:11 +00:00
chore(ci): switch auto-merge from seahaven-bot to Mergify (#43)
Some checks are pending
Deploy / deploy (push) Waiting to run
Some checks are pending
Deploy / deploy (push) Waiting to run
This commit is contained in:
parent
4de854843e
commit
0ee318eb33
2 changed files with 1 additions and 67 deletions
67
.github/workflows/auto-merge.yaml
vendored
67
.github/workflows/auto-merge.yaml
vendored
|
|
@ -1,67 +0,0 @@
|
||||||
name: Enable auto-merge
|
|
||||||
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
types: [opened, ready_for_review, reopened, synchronize]
|
|
||||||
branches: [main]
|
|
||||||
pull_request_review:
|
|
||||||
types: [submitted]
|
|
||||||
|
|
||||||
concurrency:
|
|
||||||
group: enable-auto-merge-${{ github.event.pull_request.number }}
|
|
||||||
cancel-in-progress: true
|
|
||||||
|
|
||||||
permissions:
|
|
||||||
contents: read
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable:
|
|
||||||
if: >-
|
|
||||||
github.event.pull_request.draft == false
|
|
||||||
&& github.event.pull_request.head.repo.full_name == github.repository
|
|
||||||
&& github.event.pull_request.user.login != 'dependabot[bot]'
|
|
||||||
&& github.event.pull_request.user.login != 'renovate[bot]'
|
|
||||||
&& (github.event_name != 'pull_request_review' || github.event.review.state == 'approved')
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Mint seahaven-bot token
|
|
||||||
id: app-token
|
|
||||||
uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
|
|
||||||
with:
|
|
||||||
app-id: ${{ secrets.SEAHAVEN_BOT_APP_ID }}
|
|
||||||
private-key: ${{ secrets.SEAHAVEN_BOT_PRIVATE_KEY }}
|
|
||||||
owner: Sea-Haven-Industries
|
|
||||||
repositories: ${{ github.event.repository.name }}
|
|
||||||
|
|
||||||
- name: Enqueue or arm auto-merge
|
|
||||||
env:
|
|
||||||
GH_TOKEN: ${{ steps.app-token.outputs.token }}
|
|
||||||
PR: ${{ github.event.pull_request.number }}
|
|
||||||
REPO: ${{ github.repository }}
|
|
||||||
PR_NODE_ID: ${{ github.event.pull_request.node_id }}
|
|
||||||
run: |
|
|
||||||
set -euo pipefail
|
|
||||||
in_queue="$(gh api graphql -f query='query($id:ID!) { node(id:$id) { ... on PullRequest { isInMergeQueue } } }' -f id="$PR_NODE_ID" --jq '.data.node.isInMergeQueue')"
|
|
||||||
if [ "$in_queue" = "true" ]; then
|
|
||||||
echo "already in merge queue"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
set +e
|
|
||||||
out="$(gh api graphql -f query='mutation($id:ID!) { enqueuePullRequest(input:{pullRequestId:$id}) { mergeQueueEntry { state } } }' -f id="$PR_NODE_ID" 2>&1)"
|
|
||||||
status=$?
|
|
||||||
set -e
|
|
||||||
if [ "$status" -eq 0 ]; then
|
|
||||||
printf '%s\n' "$out"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
echo "$out"
|
|
||||||
# Re-arm as seahaven-bot. A leftover GITHUB_TOKEN auto-merge would
|
|
||||||
# enqueue without starting merge_group.
|
|
||||||
gh pr merge "$PR" --repo "$REPO" --disable-auto || true
|
|
||||||
if ! gh pr merge "$PR" --repo "$REPO" --auto; then
|
|
||||||
if [ "$(gh pr view "$PR" --repo "$REPO" --json autoMergeRequest --jq '.autoMergeRequest != null')" = "true" ]; then
|
|
||||||
echo "auto-merge already enabled"
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
1
.mergify.yml
Normal file
1
.mergify.yml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
extends: .github
|
||||||
Loading…
Add table
Reference in a new issue