-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (41 loc) · 2.27 KB
/
enable-auto-merge.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
35
36
37
38
39
40
41
42
43
44
45
46
47
name: "Enable auto merge on dependabot and github actions PRs"
on:
pull_request_target:
pull_request:
types: [opened, reopened, ready_for_review]
jobs:
auto-merge:
runs-on: ubuntu-latest
permissions: write-all
if: ${{ github.event.pull_request.user.login != 'dependabot[bot]' }} # Disabled for dependabot due to security restrictions
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_TOKEN }}
- name: Enable auto merge on dependabot PRs
if: ${{ github.event.pull_request.draft == false && github.event.pull_request.user.login == 'dependabot[bot]' }}
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }} # We're using the github token here which means pushes to dev will not trigger CI
PR_NUMBER: ${{ github.event.number }}
run: gh pr merge --squash --auto $PR_NUMBER
- name: Enable auto squash merge on github actions PRs related to feature branches
if: ${{ github.event.pull_request.draft == false && (contains(github.head_ref, 'feature') || contains(github.head_ref, 'bugfix')) }}
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: gh pr merge --squash --auto $PR_NUMBER
- name: Enable auto merge on github actions PRs related to environment promotions
if: ${{ github.event.pull_request.draft == false && (github.head_ref == 'main' || github.head_ref == 'qa' || github.head_ref == 'test' || github.head_ref == 'dev') }}
env:
GH_TOKEN: ${{ secrets.WORKFLOW_TOKEN }}
PR_NUMBER: ${{ github.event.number }}
run: gh pr merge --merge --auto $PR_NUMBER
# Works only for for single person repo, or potentially it can be expanded on with a key for each user
# - name: Enable auto merge on feature PRs
# uses: daneden/enable-automerge-action@v1
# if: ${{ github.event.pull_request.draft == false && github.event.pull_request.user.login != 'dependabot[bot]' && github.event.pull_request.user.login != 'github-actions[bot]' && github.head_ref == 'dev' }}
# with:
# github-token: ${{ secrets.WORKFLOW_TOKEN }}
# allowed-author: ${{ github.event.pull_request.user.login }}
# merge-method: SQUASH