-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate_automerge_dependabot.yml
More file actions
99 lines (90 loc) · 2.94 KB
/
template_automerge_dependabot.yml
File metadata and controls
99 lines (90 loc) · 2.94 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# see: https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions#enable-auto-merge-on-a-pull-request
name: Dependabot Auto-Merge
on:
workflow_call:
inputs:
force:
default: false
required: false
type: boolean
strategy:
default: "squash"
required: false
type: string
update-types:
description: "Types of version update to allow (possible values are: minor, major, patch)"
default: "patch,minor"
required: false
type: string
include-pre-release:
description: "Include pre-release updates"
default: false
required: false
type: boolean
secrets:
app_id:
required: true
private_key:
required: true
jobs:
dependabot:
name: auto-merge
runs-on: ubuntu-slim
permissions: {}
if: github.event.pull_request.user.login == 'dependabot[bot]'
steps:
- name: Get App Token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
id: get_token
with:
app-id: ${{ secrets.app_id }}
private-key: ${{ secrets.private_key }}
- name: Load dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a # v2.5.0
with:
github-token: ${{ steps.get_token.outputs.token }}
- name: Enable auto-merge for Dependabot PRs
if: >-
(
inputs.include-pre-release ||
!startsWith(steps.metadata.outputs.previous-version, '0.')
) &&
(
(
contains(inputs.update-types, 'major') &&
steps.metadata.outputs.update-type == 'version-update:semver-major'
) ||
(
contains(inputs.update-types, 'minor') &&
steps.metadata.outputs.update-type == 'version-update:semver-minor'
) ||
(
contains(inputs.update-types, 'patch') &&
steps.metadata.outputs.update-type == 'version-update:semver-patch'
)
)
run: |
gh pr review --approve "$PR_URL"
MERGE_OPTIONS=()
case "${{ inputs.strategy }}" in
"rebase")
MERGE_OPTIONS+=("--rebase")
;;
"merge")
MERGE_OPTIONS+=("--merge")
;;
*)
MERGE_OPTIONS+=("--squash")
;;
esac
if [ "${{ inputs.force }}" == 'true' ]; then
MERGE_OPTIONS+=("--admin")
else
MERGE_OPTIONS+=("--auto")
fi
echo "Executing merge command with the options: '${MERGE_OPTIONS[*]}'"
gh pr merge "$PR_URL" "${MERGE_OPTIONS[@]}"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GITHUB_TOKEN: ${{ steps.get_token.outputs.token }}