Skip to content

Commit 5bdd66f

Browse files
committed
Add workflows for automerge and dependabot autoapprove
1 parent cc62d01 commit 5bdd66f

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
on:
2+
pull_request_review:
3+
types: submitted
4+
5+
jobs:
6+
approved_pr:
7+
name: Automerge approved PRs
8+
permissions:
9+
contents: write
10+
pull-requests: write
11+
id-token: write
12+
if: ${{ github.event.review.state == 'approved' && github.repository == 'awsdocs/aws-doc-sdk-examples' && (github.event.review.author_association == 'OWNER' || github.event.review.author_association == 'MEMBER' || github.event.review.user.login == 'aws-sdk-osds') }}
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Configure AWS credentials
16+
uses: aws-actions/configure-aws-credentials@v4
17+
with:
18+
aws-region: us-west-2
19+
role-to-assume: arn:aws:iam::206735643321:role/ConfigureAwsCredentialsPackageRole
20+
role-duration-seconds: 900
21+
role-session-name: SecretsManagerFetch
22+
- name: Get bot user token
23+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
24+
with:
25+
parse-json-secrets: true
26+
secret-ids: |
27+
OSDS,arn:aws:secretsmanager:us-west-2:206735643321:secret:github-aws-sdk-osds-automation-gebs9n
28+
- name: Enable PR automerge
29+
run: gh pr merge --auto --squash "$PR_URL"
30+
env:
31+
PR_URL: ${{ github.event.pull_request.html_url }}
32+
GITHUB_TOKEN: ${{ env.OSDS_ACCESS_TOKEN }}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Dependabot auto-approve
2+
on: pull_request
3+
permissions:
4+
pull-requests: write
5+
id-token: write
6+
jobs:
7+
dependabot:
8+
runs-on: ubuntu-latest
9+
if: ${{ github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'awsdocs/aws-doc-sdk-examples' }}
10+
steps:
11+
- name: Get Metadata
12+
id: dependabot-metadata
13+
uses: dependabot/fetch-metadata@v2
14+
- uses: actions/checkout@v4
15+
name: Clone repo
16+
- name: Configure AWS credentials
17+
uses: aws-actions/configure-aws-credentials@v4
18+
with:
19+
aws-region: us-west-2
20+
role-to-assume: arn:aws:iam::206735643321:role/ConfigureAwsCredentialsPackageRole
21+
role-duration-seconds: 900
22+
- name: Get bot user token
23+
uses: aws-actions/aws-secretsmanager-get-secrets@v2
24+
with:
25+
parse-json-secrets: true
26+
secret-ids: |
27+
OSDS,arn:aws:secretsmanager:us-west-2:206735643321:secret:github-aws-sdk-osds-automation-gebs9n
28+
- name: Approve PR if not already approved
29+
run: |
30+
gh pr checkout "$PR_URL"
31+
if [ "$(gh pr status --json reviewDecision - q .currentBranch.reviewDecision)" != "APPROVED" ]; then
32+
gh pr review "$PR_URL" --approve
33+
else echo "PR already approved"
34+
fi
35+
env:
36+
PR_URL: ${{ github.event.pull_request.html_url }}
37+
GITHUB_TOKEN: ${{ env.OSDS_ACCESS_TOKEN }}

0 commit comments

Comments
 (0)