-
Notifications
You must be signed in to change notification settings - Fork 6
61 lines (58 loc) · 1.9 KB
/
dependabot-action.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Dependabot Auto-Merge
on:
pull_request_target:
types: [review_requested]
permissions:
contents: write
pull-requests: write
packages: read
jobs:
Dependabot:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [ 20.x, 'lts/*' ]
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Dependabot metadata
id: metadata
uses: dependabot/[email protected]
with:
github-token: "${{ secrets.GH_TOKEN }}"
skip-commit-verification: true
- name: Checkout repository
uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Dependencies
run: npm install --ignore-scripts
- name: Approve PR, if not already approved
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
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Run unit tests
run: |
npm run test
- name: Aggregate Dependabot PRs
id: aggregate_prs
run: |
PR_URL=$(gh pr list --json state:open author:dependabot[bot] base:$PR_BASE_BRANCH -q '.[].url' | jq -r 'join(" ")')
echo "::set-output name=pr_url::$PR_URL"
env:
PR_BASE_BRANCH: develop
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
- name: Merge aggregated PRs
if: steps.aggregate_prs.outputs.pr_url != ''
run: |
gh pr merge --auto --merge ${{ steps.aggregate_prs.outputs.pr_url }}
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}