-
Notifications
You must be signed in to change notification settings - Fork 7
34 lines (28 loc) · 1.17 KB
/
approve.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
name: Auto approve PRs by bots
on:
# Trigger when any action on a pull request is taken.
pull_request_target:
jobs:
approve:
runs-on: ubuntu-latest
permissions:
pull-requests: write # Allows approving the PR.
contents: write # Allows merging the PR.
# Only run if one of the defined bots is the pull request author.
# https://github.com/City-of-Helsinki/tilavarauspalvelu-core/settings/variables/actions
if: contains(fromJSON(vars.BOTS), github.event.pull_request.user.login)
steps:
- name: "Check out repository"
uses: actions/checkout@v4
- name: "Approve a pull request and set to auto rebase-merge if tests pass"
# Only approve the PR if it's not already approved to avoid email spam.
run: |
gh pr checkout "$PR_URL"
if [ "$(gh pr status --json reviewDecision -q .currentBranch.reviewDecision)" != "APPROVED" ];
then gh pr review --approve "$PR_URL"
else echo "PR already approved.";
fi
gh pr merge --auto --rebase "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}