Skip to content

Commit 94a217c

Browse files
committed
Add automerge workflow for successful pull request merges
1 parent 200cddf commit 94a217c

2 files changed

Lines changed: 32 additions & 11 deletions

File tree

.github/workflows/automerge.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: automerge
2+
3+
on:
4+
workflow_run:
5+
workflows: [ tests ]
6+
types: [ completed ]
7+
8+
jobs:
9+
merge:
10+
if: |
11+
github.event.workflow_run.conclusion == 'success' &&
12+
github.event.workflow_run.event == 'pull_request' &&
13+
startsWith(github.event.workflow_run.head_branch, 'update-models-metadata')
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
steps:
19+
- name: Merge PR
20+
env:
21+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
22+
REPO: ${{ github.repository }}
23+
BRANCH: ${{ github.event.workflow_run.head_branch }}
24+
run: |
25+
PR_NUMBER=$(gh pr list --repo "$REPO" --head "$BRANCH" --state open --json number --jq '.[0].number')
26+
if [ -n "$PR_NUMBER" ]; then
27+
gh pr merge "$PR_NUMBER" \
28+
--merge \
29+
--delete-branch \
30+
--subject "Update the models metadata (GH-${PR_NUMBER})" \
31+
--body "Co-authored-by: Artyom Vancyan <44609997+artyomvancyan@users.noreply.github.com>"
32+
fi

.github/workflows/models.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,3 @@ jobs:
4444
title: Update the models metadata
4545
commit-message: Update the models metadata
4646
body: This PR updates the models metadata to keep the repository up-to-date with the upstream model costs.
47-
48-
- name: Enable auto-merge
49-
if: steps.create-pr.outputs.pull-request-number != ''
50-
env:
51-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
52-
run: |
53-
gh pr merge ${{ steps.create-pr.outputs.pull-request-number }} \
54-
--auto \
55-
--merge \
56-
--subject "Update the models metadata (GH-${{ steps.create-pr.outputs.pull-request-number }})" \
57-
--body "Co-authored-by: Artyom Vancyan <44609997+artyomvancyan@users.noreply.github.com>"

0 commit comments

Comments
 (0)