-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yml
66 lines (64 loc) · 2.37 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
name: Commit artifact to branch
description: Commit a GitHub uploaded artifact to a target branch. This is useful for, e.g., committing build output to gh-pages.
inputs:
token:
required: true
type: string
description: a GitHub token to use when committing. If the commit should trigger further workflows (for e.g., a GitHub Pages deployment flow), make sure to use a PAT.
branch:
required: true
type: string
description: the branch name to commit to
artifact-name:
required: true
type: string
description: the name of an artifact (previously uploaded with actions/upload-artifact)
dest:
required: false
type: string
default: ''
description: the destination directory to commit the artifact into
commit-author-name:
required: false
type: string
default: 'Continuous Integration'
description: the Git author name for the generated commit
commit-author-email:
required: false
type: string
default: ''
description: the Git author email for the generated commit
commit-message:
required: false
type: string
default: 'Committing GitHub Actions workflow artifact'
description: the Git commit message
runs:
using: composite
steps:
- uses: actions/checkout@v3
with:
ref: ${{ inputs.branch }}
path: .commit-artifact-to-branch-${{ inputs.artifact-name }}-${{ inputs.branch }}
token: ${{ inputs.token }}
- name: Clear dest
run: rm -rfv ./'${{ inputs.dest }}'/*
shell: bash
working-directory: .commit-artifact-to-branch-${{ inputs.artifact-name }}-${{ inputs.branch }}
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: .commit-artifact-to-branch-${{ inputs.artifact-name }}-${{ inputs.branch }}/${{ inputs.dest }}
- name: Commit artifact
run: |
git config user.name '${{ inputs.commit-author-name }}'
git config user.email '${{ inputs.commit-author-email }}'
git add ./'${{ inputs.dest }}'
git diff-index --quiet --cached HEAD -- && {
echo 'Nothing to commit; exiting'
exit 0
}
git commit -m '${{ inputs.commit-message }}' --allow-empty-message
git push --force-with-lease origin '${{ inputs.branch }}'
shell: bash
working-directory: .commit-artifact-to-branch-${{ inputs.artifact-name }}-${{ inputs.branch }}