-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (62 loc) · 2.68 KB
/
Copy pathdependabot-automerge.yml
File metadata and controls
69 lines (62 loc) · 2.68 KB
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
62
63
64
65
66
67
68
69
name: Dependabot auto-merge
on: pull_request
permissions:
contents: write
pull-requests: write
jobs:
dependabot:
runs-on: ubuntu-latest
if: github.actor == 'dependabot[bot]'
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v3
with:
github-token: "${{ secrets.GITHUB_TOKEN }}"
# Security-sensitive packages are excluded from auto-merge so a
# compromised upstream release cannot ship to consumers without a
# human eyeballing the diff. These are the packages whose code
# directly renders or sanitizes user-controlled content (links,
# markdown, block payloads) — a malicious minor release here is
# the worst case for our supply-chain posture.
- name: Check exclusion list
id: excluded
env:
PACKAGE_NAMES: ${{ steps.metadata.outputs.dependency-names }}
run: |
set -euo pipefail
excluded=false
IFS=', ' read -r -a names <<< "$PACKAGE_NAMES"
for pkg in "${names[@]}"; do
case "$pkg" in
slack-blocks-to-jsx|react-markdown|remark-gfm|@tiptap/extension-link|@tiptap/starter-kit|@tiptap/core|@tiptap/react|@tiptap/pm|@tightknitai/slack-block-kit-validator|ajv|ajv-formats|slack-web-api-client)
excluded=true
;;
esac
done
echo "excluded=$excluded" >> "$GITHUB_OUTPUT"
- name: Enable auto-merge for minor/patch updates
if: |
steps.metadata.outputs.update-type != 'version-update:semver-major' &&
steps.excluded.outputs.excluded != 'true'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Approve PR
if: |
steps.metadata.outputs.update-type != 'version-update:semver-major' &&
steps.excluded.outputs.excluded != 'true'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Comment when held for manual review
if: |
steps.metadata.outputs.update-type != 'version-update:semver-major' &&
steps.excluded.outputs.excluded == 'true'
run: |
gh pr comment "$PR_URL" --body "Held for manual review: \`${{ steps.metadata.outputs.dependency-names }}\` is on the security-sensitive auto-merge exclusion list. Verify the changelog and source diff before merging."
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}