Repository navigation
Expand file tree
/
Copy pathaction.yml
More file actions
134 lines (113 loc) · 3.81 KB
/
Copy pathaction.yml
File metadata and controls
134 lines (113 loc) · 3.81 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
name: Autocommit Github Changes
author: kassett
description: "This GitHub Action allows you to commit changes to git in a runner."
inputs:
branch:
description: "The branch to commit to or base branch for PR."
required: true
github-token:
description: "The GitHub token used by gh CLI."
required: true
use-pull-request:
description: "Create PR instead of direct commit."
required: false
default: "false"
files:
description: "Comma-separated list of files to commit. Mutually exclusive with commit-all."
required: false
default: ""
commit-all:
description: "Whether to commit all tracked changes. Mutually exclusive with files."
required: false
default: "false"
commit-message:
description: "Message to use for the commit."
required: false
default: "Auto-committed changes"
pull-request-title:
description: "Title of the PR, if applicable."
required: false
default: "Auto-generated PR"
pull-request-body:
description: "Body of the PR, if applicable."
required: false
default: "PR created by GitHub Actions."
pull-request-labels:
description: "Labels to attach to the PR."
required: false
default: ""
pull-request-branch-name:
description: "Custom name for the PR branch. Otherwise will be randomly generated from target branch."
required: false
default: ""
commit-untracked-files:
description: "Whether to include untracked files."
required: false
default: "false"
outputs:
sha:
description: "The commit made by the action."
value: ${{ steps.commit.outputs.sha }}
branch:
description: "The name of the branch created for the PR."
value: ${{ steps.commit.outputs.branch }}
pr-number:
description: "The number of the PR created."
value: ${{ steps.commit.outputs.pr-number }}
runs:
using: composite
steps:
- name: Install gh-commit extension
shell: bash
run: gh extension install kassett/gh-commit
env:
GH_TOKEN: ${{ inputs.github-token }}
- name: Run gh-commit
id: commit
shell: bash
env:
GH_TOKEN: ${{ inputs.github-token }}
BRANCH: "${{ inputs.branch }}"
MESSAGE: "${{ inputs.commit-message }}"
USE_PR: "${{ inputs.use-pull-request }}"
HEAD_REF: "${{ inputs.pull-request-branch-name }}"
TITLE: "${{ inputs.pull-request-title }}"
BODY: "${{ inputs.pull-request-body }}"
FILES: "${{ inputs.files }}"
UNTRACKED: "${{ inputs.commit-untracked-files }}"
COMMIT_ALL: "${{ inputs.commit-all }}"
LABELS: "${{ inputs.pull-request-labels }}"
run: |
if [[ -n "$FILES" && "$COMMIT_ALL" == "true" ]]; then
echo "❌ Error: inputs 'files' and 'commit-all' are mutually exclusive."
exit 1
fi
if [ -z "$MESSAGE" ] || [ "$MESSAGE" = '""' ]; then
echo "❌ Error: input 'message' cannot be an empty string."
exit 1
fi
ARGS="-B \"$BRANCH\" -m \"$MESSAGE\""
if [[ "$USE_PR" == "true" ]]; then
ARGS+=" -P"
[[ -n "$HEAD_REF" ]] && ARGS+=" -H \"$HEAD_REF\""
[[ -n "$TITLE" ]] && ARGS+=" -T \"$TITLE\""
[[ -n "$BODY" ]] && ARGS+=" -D \"$BODY\""
fi
if [[ -n "$LABELS" ]]; then
IF=',' read -ra LABEL_ARR <<< "$LABELS"
for l in "${LABEL_ARR[@]}"; do
ARGS+=" -l \"$l\""
done
fi
if [[ "$COMMIT_ALL" == "true" ]]; then
ARGS+=" -A"
if [[ "$UNTRACKED" == "true" ]]; then
ARGS+=" -U"
fi
elif [[ -n "$FILES" ]]; then
IFS=$' \t,' read -ra FILE_ARR <<< "$FILES"
for f in "${FILE_ARR[@]}"; do
ARGS+=" \"$f\""
done
fi
eval gh commit $ARGS