-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
66 lines (55 loc) · 2.2 KB
/
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
62
63
64
65
66
inputs:
update_command:
description: "A command to update all dependencies"
required: false
default: "just update-dependencies"
on_changes_command:
description: "A command to run after dependencies have been updated"
required: false
token:
description: "The token that the action will use to create and update the pull request."
default: ${{ github.token }}
commit_message:
description: "Commit message if changes found"
required: false
default: "chore: update-dependencies"
pr_title:
description: "Title for the PR"
required: false
default: "Update dependencies"
automerge:
description: "Enable automerge on PRs created by the action"
default: true
runs:
using: "composite"
steps:
- name: Update dependencies
shell: bash
run: ${{ inputs.update_command }}
- name: Check for changes
shell: bash
id: check_for_changes
run: echo "changed=$(git diff -s --exit-code || echo 1)" >> "$GITHUB_OUTPUT"
- name: Run command if changes found
shell: bash
if: ${{ (steps.check_for_changes.outputs.changed) && (inputs.on_changes_command) }}
run: ${{ inputs.on_changes_command }}
- name: Create a Pull Request if there are any changes
id: create_pr
uses: peter-evans/create-pull-request@v7.0.5
with:
branch: bot/update-dependencies
base: main
author: "opensafely-github-bot <opensafely-github-bot@users.noreply.github.com>"
committer: "opensafely-github-bot <opensafely-github-bot@users.noreply.github.com>"
commit-message: ${{ inputs.commit_message }}
title: ${{ inputs.pr_title }}
body: Automated changes by [update-dependencies-action](https://github.com/bennettoxford/update-dependencies-action)
token: ${{ inputs.token }}
# The PR will still need to pass any required checks, this just reduces it to a one-click process
- name: Enable automerge
shell: bash
if: ${{ (steps.create_pr.outputs.pull-request-operation == 'created') && (inputs.automerge == 'true') }}
run: gh pr merge --auto --squash ${{ steps.create_pr.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ inputs.token }}