-
Notifications
You must be signed in to change notification settings - Fork 112
Expand file tree
/
Copy pathaction.yml
More file actions
91 lines (84 loc) · 3.51 KB
/
action.yml
File metadata and controls
91 lines (84 loc) · 3.51 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
name: Set Up Gradle and Run Task
description: This action performs a "fix"-type Gradle task and commits/pushes changes if possible.
inputs:
java-version:
description: 'The Java version to set up'
default: '17'
distribution:
description: 'The JDK distribution to use'
default: 'zulu'
fix-task:
description: 'The task to be executed if the user has a PAT and the branch is not a fork'
required: true
check-task:
description: 'The task to be executed if the user does not have a PAT or the branch is a fork'
required: true
commit-message:
description: 'The commit message to use if changes are generated'
default: ''
access-token:
description: 'The access token to use for checkouts.'
restore-cache-key:
description: 'The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
default: 'null'
write-cache-key:
description: 'The unique identifier for the associated cache. Any other consumers or producers for this cache must use the same name.'
default: 'null'
runs:
using: 'composite'
steps:
- name: Check if we can push
id: can-push
shell: bash
run: |
if [[ "${{ inputs.access-token }}" == '' ]]; then
echo "can_push=false" >> $GITHUB_OUTPUT
elif [[ "${{ env.GITHUB_REF_PROTECTED }}" == 'true' ]]; then
echo "can_push=false" >> $GITHUB_OUTPUT
elif [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
echo "can_push=false" >> $GITHUB_OUTPUT
else
echo "can_push=true" >> $GITHUB_OUTPUT
fi
# ensure that we have the actual branch checked out. By default, actions/checkout is headless.
- name: check out with the generated app token
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
if: steps.can-push.outputs.can_push == 'true'
with:
token: ${{ inputs.access-token }}
ref: ${{ github.head_ref }}
fetch-depth: 0
- name: Run ${{ inputs.fix-task }}
if: steps.can-push.outputs.can_push == 'true'
uses: ./.github/actions/gradle-task
with:
task: ${{ inputs.fix-task }}
distribution: ${{ inputs.distribution }}
java-version: ${{ inputs.java-version }}
restore-cache-key: ${{ inputs.restore-cache-key }}
write-cache-key: ${{ inputs.write-cache-key }}
- name: Set Commit Message
id: set-commit-message
if: steps.can-push.outputs.can_push == 'true'
shell: bash
run: |
if [[ -z "${{ inputs.commit-message }}" ]]; then
echo "commit-message=Apply changes from ${{ inputs.fix-task }}" >> $GITHUB_OUTPUT
else
echo "commit-message=${{ inputs.commit-message }}" >> $GITHUB_OUTPUT
fi
- name: commit ${{ inputs.fix-task }} changes
if: steps.can-push.outputs.can_push == 'true'
uses: stefanzweifel/git-auto-commit-action@04702edda442b2e678b25b537cec683a1493fcb9 # v7
with:
commit_message: ${{ steps.set-commit-message.outputs.commit-message }}
commit_options: '--no-verify --signoff'
- name: Run ${{ inputs.check-task }}
if: steps.can-push.outputs.can_push != 'true'
uses: ./.github/actions/gradle-task
with:
task: ${{ inputs.check-task }}
distribution: ${{ inputs.distribution }}
java-version: ${{ inputs.java-version }}
restore-cache-key: ${{ inputs.restore-cache-key }}
write-cache-key: ${{ inputs.write-cache-key }}