Skip to content

Commit a57eb7a

Browse files
feat: added suport for azure checks for auto merge workflow (#253)
Co-authored-by: NotMaharshi <[email protected]>
1 parent aea393b commit a57eb7a

File tree

1 file changed

+51
-6
lines changed

1 file changed

+51
-6
lines changed

.github/workflows/auto_merge.yml

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,16 @@ on:
88
description: 'Enter the tfcheck action name.'
99
required: false
1010
type: string
11+
tfchecks_azure:
12+
description: 'List of Azure TF checks (JSON array as string)'
13+
required: false
14+
type: string
15+
default: '["pr-validation / 📝 Validate PR title", "pr-validation / 🧾 Validate Commit Messages", "tf-lint / tflint"]'
16+
azure_cloud:
17+
description: 'Enable Azure-specific checks'
18+
required: false
19+
type: boolean
20+
default: false
1121
secrets:
1222
GITHUB:
1323
description: 'GitHub Token'
@@ -20,7 +30,35 @@ jobs:
2030
strategy:
2131
matrix:
2232
tf-checks: ["tf-lint / tflint", "tfsec / tfsec sarif report", "${{ inputs.tfcheck }}"]
23-
if: github.actor == 'dependabot[bot]'
33+
if: github.actor == 'dependabot[bot]' && !inputs.azure_cloud
34+
steps:
35+
- name: Wait for 2 Minutes
36+
run: sleep 120s
37+
shell: bash
38+
39+
- name: Wait for "${{ matrix.tf-checks }}" to Succeed
40+
uses: lewagon/[email protected]
41+
with:
42+
ref: ${{ github.event.pull_request.head.sha }}
43+
check-name: ${{ matrix.tf-checks }}
44+
repo-token: ${{ secrets.GITHUB || secrets.GITHUB_TOKEN }}
45+
wait-interval: 30
46+
allowed-conclusions: success
47+
48+
static-checks-azure:
49+
name: Check Static Analysis for Azure
50+
runs-on: ubuntu-latest
51+
permissions:
52+
contents: read
53+
checks: read
54+
pull-requests: read
55+
if: |
56+
github.actor == 'dependabot[bot]' &&
57+
inputs.azure_cloud == true &&
58+
inputs.tfchecks_azure != '[]'
59+
strategy:
60+
matrix:
61+
tf-checks: ${{ fromJSON(inputs.tfchecks_azure) }}
2462
steps:
2563
- name: Wait for 2 Minutes
2664
run: sleep 120s
@@ -31,7 +69,7 @@ jobs:
3169
with:
3270
ref: ${{ github.event.pull_request.head.sha }}
3371
check-name: ${{ matrix.tf-checks }}
34-
repo-token: ${{ secrets.GITHUB }}
72+
repo-token: ${{ secrets.GITHUB || secrets.GITHUB_TOKEN }}
3573
wait-interval: 30
3674
allowed-conclusions: success
3775

@@ -40,9 +78,12 @@ jobs:
4078
contents: write
4179
pull-requests: write
4280
name: Auto Approve PRs by Dependabot
43-
needs: static-checks
81+
needs: [static-checks, static-checks-azure]
4482
runs-on: ubuntu-latest
45-
if: github.actor == 'dependabot[bot]'
83+
if: |
84+
always() &&
85+
github.actor == 'dependabot[bot]' &&
86+
(needs.static-checks.result == 'success' || needs.static-checks-azure.result == 'success')
4687
steps:
4788
- name: Approve PR via GitHub Bot
4889
run: gh pr review --approve "$PR_URL"
@@ -59,15 +100,19 @@ jobs:
59100
automerge:
60101
runs-on: ubuntu-latest
61102
needs: autoapprove
103+
if: |
104+
always() &&
105+
needs.autoapprove.result == 'success' &&
106+
github.event_name == 'pull_request' &&
107+
github.event.pull_request.draft == false
62108
steps:
63109
- name: Automerge
64110
uses: pascalgn/[email protected]
65-
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
66111
env:
67112
GITHUB_TOKEN: ${{ secrets.GITHUB }}
68113
MERGE_FILTER_AUTHOR: 'dependabot[bot]'
69114
MERGE_METHOD: "merge"
70115
MERGE_DELETE_BRANCH: "true"
71116
MERGE_LABELS: "dependencies, github_actions"
72117
MERGE_REQUIRED_APPROVALS: ""
73-
...
118+
...

0 commit comments

Comments
 (0)