Repository navigation
69 lines (61 loc) · 2.22 KB
/
Copy pathdependabot-auto-merge.yml
File metadata and controls
69 lines (61 loc) · 2.22 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_target:
types: [opened, synchronize, reopened, labeled]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
dependabot-auto-merge:
if: github.actor == 'dependabot[bot]'
runs-on: ubuntu-latest
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@7a4b92f93a688100997537756415299e15fc2431 # v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Decide if PR is eligible for auto-merge
id: eligible
env:
ECOSYSTEM: ${{ steps.metadata.outputs.package-ecosystem }}
UPDATE_TYPE: ${{ steps.metadata.outputs.update-type }}
DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }}
run: |
set -e
eligible=false
case "$ECOSYSTEM" in
npm|gomod|pip)
if [[ "$UPDATE_TYPE" == "version-update:semver-patch" ]]; then
eligible=true
fi
;;
github_actions)
if [[ "$UPDATE_TYPE" == "version-update:semver-patch" || "$UPDATE_TYPE" == "version-update:semver-minor" ]]; then
trusted=true
IFS=',' read -ra names <<< "$DEPENDENCY_NAMES"
for raw in "${names[@]}"; do
name="$(echo "$raw" | xargs)"
case "$name" in
actions/checkout|actions/setup-node|actions/setup-go|actions/setup-python|pnpm/action-setup)
;;
*)
trusted=false
;;
esac
done
if [[ "$trusted" == "true" ]]; then
eligible=true
fi
fi
;;
esac
echo "eligible=$eligible" >> "$GITHUB_OUTPUT"
- name: Enable auto-merge for eligible updates
if: steps.eligible.outputs.eligible == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr merge --auto --squash "${{ github.event.pull_request.html_url }}"