-
Notifications
You must be signed in to change notification settings - Fork 3
/
action.yml
93 lines (88 loc) · 2.95 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
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
name: Update Gradle dependencies and plugins
description: Uses com.markelliot.versions to update dependencies and plugins
branding:
icon: arrow-up-circle
color: blue
inputs:
push-to-repo-token:
description: a GitHub Personal Access Token capable of pushing to the target repository
required: true
commit-user:
description: the username to use when creating an update commit
required: true
default: auto-updater
commit-email:
description: the email address to use when creating an update commit, typically "<user>@users.noreply.github.com"
required: true
commit-title:
description: the title to use for the commit
required: true
default: Auto-update dependencies and plugins
primary-branch:
description: the branch to target updates
required: true
default: develop
working-branch:
description: the branch from which to submit updates
required: true
default: auto/versions
pr-title:
description: the title to use for the PR
required: true
default: Auto-update dependencies and plugins
label:
description: The name of a label to add to the PR
format:
default: false
runs:
using: composite
steps:
- name: Check for new versions
shell: bash
run: ./gradlew checkNewVersions
- name: Apply version updates
shell: bash
run: ./gradlew updateAll
- name: Write lockfile
shell: bash
run: ./gradlew --write-locks
- name: Format
if: inputs.format == 'true'
shell: bash
run: ./gradlew format
- name: Create branch and commit changes
if: ${{ always() }}
shell: bash
run: |
# only commit if there are changes
if [ -z "$(git status --porcelain)" ]
then
echo "No updates detected"
exit 0
fi
git config --local user.name '${{ inputs.commit-user }}'
git config --local user.email '${{ inputs.commit-email }}'
git checkout -B "${{ inputs.working-branch }}"
git commit -am '${{ inputs.commit-title }}'
# only push changes if different
if [ -n "$(git ls-remote --exit-code origin '${{ inputs.working-branch }}')" ] && [ -z "$(git diff 'origin/${{ inputs.working-branch }}')" ]
then
echo "No new updates since last update proposal"
exit 0
fi
git push origin -f '${{ inputs.working-branch }}'
if [[ -f "build/com.markelliot.versions/report.md" ]]
then
export BODY=$(cat build/com.markelliot.versions/report.md)
else
export BODY=""
fi
gh pr create -B "${{ inputs.primary-branch }}" --title "${{ inputs.pr-title }}" --body "${BODY}" || true
# update the PR body to set versions if different than creation
gh pr edit --body "${BODY}"
if [ -n "${{ inputs.label }}" ];
then
gh pr edit --add-label "${{ inputs.label }}"
fi
env:
GITHUB_TOKEN: "${{ inputs.push-to-repo-token }}"