Skip to content

Commit 1ef2195

Browse files
Feat: Add auto-approve and merge shared workflow. (#107)
Co-authored-by: Anmol Nagpal <[email protected]>
1 parent 05ebccf commit 1ef2195

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed

.github/workflows/auto_merge.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
---
2+
name: Automerge
3+
4+
on:
5+
workflow_call:
6+
inputs:
7+
tfcheck:
8+
description: 'Enter the tfcheck action name.'
9+
required: false
10+
type: string
11+
secrets:
12+
GITHUB:
13+
description: 'GitHub Token'
14+
required: false
15+
16+
jobs:
17+
static-checks:
18+
name: Check the status of static checks
19+
runs-on: ubuntu-latest
20+
strategy:
21+
matrix:
22+
tf-checks: ["tf-lint / tflint", "tfsec / tfsec sarif report", "${{ inputs.tfcheck }}"]
23+
if: github.actor == 'dependabot[bot]'
24+
steps:
25+
- name: Wait for "${{ matrix.tf-checks }}" to succeed
26+
uses: lewagon/[email protected]
27+
with:
28+
ref: ${{ github.event.pull_request.head.sha }}
29+
check-name: ${{ matrix.tf-checks }}
30+
repo-token: ${{ secrets.GITHUB }}
31+
wait-interval: 30
32+
33+
autoapprove:
34+
permissions:
35+
contents: write
36+
pull-requests: write
37+
name: Auto Approve a PR by dependabot
38+
needs: static-checks
39+
runs-on: ubuntu-latest
40+
if: github.actor == 'dependabot[bot]'
41+
steps:
42+
- name: Approve a PR for Github Bot
43+
run: gh pr review --approve "$PR_URL"
44+
env:
45+
PR_URL: ${{github.event.pull_request.html_url}}
46+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
47+
48+
- name: Approve a PR for Anmol nagpal
49+
run: gh pr review --approve "$PR_URL"
50+
env:
51+
PR_URL: ${{github.event.pull_request.html_url}}
52+
GITHUB_TOKEN: ${{secrets.GITHUB}}
53+
54+
automerge:
55+
runs-on: ubuntu-latest
56+
needs: autoapprove
57+
steps:
58+
- id: automerge
59+
name: automerge
60+
uses: pascalgn/[email protected]
61+
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB }}
64+
MERGE_FILTER_AUTHOR: 'dependabot[bot]'
65+
MERGE_METHOD: "merge"
66+
MERGE_DELETE_BRANCH: "true"
67+
MERGE_LABELS: "dependencies"
68+
MERGE_REQUIRED_APPROVALS: ""
69+
...

0 commit comments

Comments
 (0)