fix auto merge when there's sync label (#4715)
Co-authored-by: Suchintan <suchintan@users.noreply.github.com>
This commit is contained in:
63
.github/workflows/auto-merge-sync.yml
vendored
63
.github/workflows/auto-merge-sync.yml
vendored
@@ -1,49 +1,56 @@
|
|||||||
name: Auto-merge sync PRs
|
name: Auto-merge sync PRs
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
types: [labeled, opened, synchronize, reopened]
|
types: [opened, reopened, ready_for_review, labeled, synchronize]
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: write
|
||||||
|
checks: read
|
||||||
jobs:
|
jobs:
|
||||||
auto-merge:
|
auto-merge:
|
||||||
|
if: >
|
||||||
|
contains(join(github.event.pull_request.labels.*.name, ','), 'sync') && contains('suchintan,wintonzheng,LawyZheng,pedrohsdb,marcmuon,celalzamanoglu', github.event.pull_request.user.login)
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
if: contains(github.event.pull_request.labels.*.name, 'sync')
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Wait for all required checks to pass
|
||||||
|
uses: lewagon/wait-on-check-action@v1.4.1
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
wait-interval: 10
|
||||||
|
ignore-checks: auto-merge
|
||||||
- name: Set token for author
|
- name: Set token for author
|
||||||
id: set-token
|
id: set-token
|
||||||
run: |
|
run: |
|
||||||
PR_AUTHOR="${{ github.event.pull_request.user.login }}"
|
case "${{ github.event.pull_request.user.login }}" in
|
||||||
echo "author=$PR_AUTHOR" >> $GITHUB_OUTPUT
|
wintonzheng)
|
||||||
|
echo "GH_PAT=${{ secrets.SKYVERN_OSS_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
case "$PR_AUTHOR" in
|
|
||||||
"wintonzheng")
|
|
||||||
echo "token_name=WINTON_GH_PAT" >> $GITHUB_OUTPUT
|
|
||||||
;;
|
;;
|
||||||
"LawyZheng")
|
LawyZheng)
|
||||||
echo "token_name=LAWY_GH_PAT" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.LAWY_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
"suchintan")
|
suchintan)
|
||||||
echo "token_name=SUCHINTAN_GH_PAT" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.SUCHINTAN_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
"pedrohsdb")
|
pedrohsdb)
|
||||||
echo "token_name=PEDRO_GH_PAT" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.PEDROHSDB_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
"marcmuon")
|
marcmuon)
|
||||||
echo "token_name=MARC_GH_PAT" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.MARC_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
"celalzamanoglu")
|
celalzamanoglu)
|
||||||
echo "token_name=CELAL_GH_PAT" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.CELAL_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "token_name=" >> $GITHUB_OUTPUT
|
echo "GH_PAT=${{ secrets.SKYVERN_OSS_GH_PAT }}" >> $GITHUB_OUTPUT
|
||||||
echo "Author $PR_AUTHOR is not in the approved list"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
- name: Auto-merge PR
|
- name: Auto-merge PR
|
||||||
if: steps.set-token.outputs.token_name != ''
|
|
||||||
run: |
|
|
||||||
echo "Merging PR for author ${{ steps.set-token.outputs.author }}"
|
|
||||||
gh pr merge ${{ github.event.pull_request.number }} \
|
|
||||||
--repo ${{ github.repository }} \
|
|
||||||
--squash \
|
|
||||||
--admin
|
|
||||||
env:
|
env:
|
||||||
GH_TOKEN: ${{ secrets[steps.set-token.outputs.token_name] }}
|
GH_TOKEN: ${{ steps.set-token.outputs.GH_PAT }}
|
||||||
|
run: |
|
||||||
|
gh pr merge ${{ github.event.pull_request.number }} \
|
||||||
|
--squash \
|
||||||
|
--admin \
|
||||||
|
--repo "${{ github.repository }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user