You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+37-22Lines changed: 37 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ Adding git-auto-commit to your Workflow only takes a couple lines of code.
16
16
2. Add the following step at the end of your job, after other steps that might add or change files.
17
17
18
18
```yaml
19
-
- uses: step-security/git-auto-commit-action@v5
19
+
- uses: step-security/git-auto-commit-action@v7
20
20
```
21
21
22
22
Your Workflow should look similar to this example.
@@ -36,15 +36,15 @@ jobs:
36
36
contents: write
37
37
38
38
steps:
39
-
- uses: actions/checkout@v4
39
+
- uses: actions/checkout@v5
40
40
with:
41
41
ref: ${{ github.head_ref }}
42
42
43
43
# Other steps that change files in the repository go here
44
44
# …
45
45
46
46
# Commit all changed files back to the repository
47
-
- uses: step-security/git-auto-commit-action@v5
47
+
- uses: step-security/git-auto-commit-action@v7
48
48
```
49
49
50
50
> [!NOTE]
@@ -53,7 +53,7 @@ jobs:
53
53
The following is an extended example with all available options.
54
54
55
55
```yaml
56
-
- uses: step-security/git-auto-commit-action@v5
56
+
- uses: step-security/git-auto-commit-action@v7
57
57
with:
58
58
# Optional. Commit message for the created commit.
59
59
# Defaults to "Apply automatic changes"
@@ -82,10 +82,15 @@ The following is an extended example with all available options.
82
82
commit_user_name: My GitHub Actions Bot # defaults to "github-actions[bot]"
83
83
commit_user_email: [email protected]# defaults to "41898282+github-actions[bot]@users.noreply.github.com"
84
84
commit_author: Author <[email protected]> # defaults to "username <[email protected]>", where "numeric_id" and "username" belong to the author of the commit that triggered the run
85
+
86
+
# Optional. Tag name to be created in the local repository and
87
+
# pushed to the remote repository on the defined branch.
88
+
# If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message.
89
+
tag_name: 'v1.0.0'
85
90
86
-
# Optional. Tag name being created in the local repository and
87
-
#pushed to remote repository and defined branch.
88
-
tagging_message: 'v1.0.0'
91
+
# Optional. Message to annotate the created tag with.
92
+
#If only one of `tag_name` or `tagging_message` is provided, the value of the provided field will be used for both tag name and message.
93
+
tagging_message: 'Codename "Sunshine"'
89
94
90
95
# Optional. Option used by `git-status` to determine if the repository is
91
96
# dirty. See https://git-scm.com/docs/git-status#_options
@@ -102,12 +107,21 @@ The following is an extended example with all available options.
102
107
# Optional. Disable dirty check and always try to create a commit and push
103
108
skip_dirty_check: true
104
109
110
+
# Optional. Skip internal call to `git fetch`
111
+
skip_fetch: true
112
+
113
+
# Optional. Skip internal call to `git checkout`
114
+
skip_checkout: true
115
+
105
116
# Optional. Prevents the shell from expanding filenames.
# Optional. Create given branch name in local and remote repository.
121
+
create_branch: true
122
+
109
123
# Optional. Creates a new tag and pushes it to remote without creating a commit.
110
-
# Skips dirty check and changed files. Must be used with `tagging_message`.
124
+
# Skips dirty check and changed files. Must be used in combination with `tag` and `tagging_message`.
111
125
create_git_tag_only: false
112
126
```
113
127
@@ -138,14 +152,14 @@ jobs:
138
152
contents: write
139
153
140
154
steps:
141
-
- uses: actions/checkout@v4
155
+
- uses: actions/checkout@v5
142
156
with:
143
157
ref: ${{ github.head_ref }}
144
158
145
159
- name: Run php-cs-fixer
146
160
uses: docker://oskarstark/php-cs-fixer-ga
147
161
148
-
- uses: step-security/git-auto-commit-action@v5
162
+
- uses: step-security/git-auto-commit-action@v7
149
163
with:
150
164
commit_message: Apply php-cs-fixer changes
151
165
```
@@ -167,7 +181,7 @@ You can use these outputs to trigger other Actions in your Workflow run based on
167
181
### Example
168
182
169
183
```yaml
170
-
- uses: step-security/git-auto-commit-action@v5
184
+
- uses: step-security/git-auto-commit-action@v7
171
185
id: auto-commit-action #mandatory for the output to show up in ${{ steps }}
172
186
with:
173
187
commit_message: Apply php-cs-fixer changes
@@ -203,7 +217,7 @@ You must use `action/checkout@v2` or later versions to check out the repository.
203
217
In non-`push` events, such as `pull_request`, make sure to specify the `ref` to check out:
204
218
205
219
```yaml
206
-
- uses: actions/checkout@v4
220
+
- uses: actions/checkout@v5
207
221
with:
208
222
ref: ${{ github.head_ref }}
209
223
```
@@ -221,7 +235,7 @@ You can change this by creating a new [Personal Access Token (PAT)](https://gith
221
235
storing the token as a secret in your repository and then passing the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step.
222
236
223
237
```yaml
224
-
- uses: actions/checkout@v4
238
+
- uses: actions/checkout@v5
225
239
with:
226
240
token: ${{ secrets.PAT }}
227
241
```
@@ -267,7 +281,7 @@ The example below can be used as a starting point to generate a multiline commit
267
281
# Quick and dirty step to get rid of the temporary file holding the commit message
# Checkout the fork/head-repository and push changes to the fork.
357
371
# If you skip this, the base repository will be checked out and changes
@@ -365,7 +379,7 @@ jobs:
365
379
- name: Run php-cs-fixer
366
380
uses: docker://oskarstark/php-cs-fixer-ga
367
381
368
-
- uses: step-security/git-auto-commit-action@v5
382
+
- uses: step-security/git-auto-commit-action@v7
369
383
```
370
384
371
385
For more information about running Actions on forks, see [this announcement from GitHub](https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/).
@@ -400,12 +414,13 @@ The steps in your workflow might look like this:
@@ -439,7 +454,7 @@ If you create a personal access token (classic), apply the `repo` and `workflow`
439
454
If you create a fine-grained personal access token, apply the `Contents`-permissions.
440
455
441
456
```yaml
442
-
- uses: actions/checkout@v4
457
+
- uses: actions/checkout@v5
443
458
with:
444
459
# We pass the "PAT" secret to the checkout action; if no PAT secret is available to the workflow runner (eg. Dependabot) we fall back to the default "GITHUB_TOKEN".
445
460
token: ${{ secrets.PAT || secrets.GITHUB_TOKEN }}
@@ -453,7 +468,7 @@ You can learn more about Personal Access Token in the [GitHub documentation](htt
453
468
If you go the "force pushes" route, you have to enable force pushes to a protected branch (see [documentation](https://help.github.com/en/github/administering-a-repository/enabling-force-pushes-to-a-protected-branch)) and update your Workflow to use force push like this.
454
469
455
470
```yaml
456
-
- uses: step-security/git-auto-commit-action@v5
471
+
- uses: step-security/git-auto-commit-action@v7
457
472
with:
458
473
commit_message: Apply php-cs-fixer changes
459
474
push_options: --force
@@ -482,7 +497,7 @@ This is due to the fact, that the `*.md`-glob is expanded before sending it to `
482
497
To fix this add `disable_globbing: true` to your Workflow.
483
498
484
499
```yaml
485
-
- uses: step-security/git-auto-commit-action@v5
500
+
- uses: step-security/git-auto-commit-action@v7
486
501
with:
487
502
file_pattern: '*.md'
488
503
disable_globbing: true
@@ -509,7 +524,7 @@ yarn test
509
524
510
525
We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/step-security/git-auto-commit-action/tags).
511
526
512
-
We also provide major version tags to make it easier to always use the latest release of a major version. For example, you can use `step-security/git-auto-commit-action@v5` to always use the latest release of the current major version.
527
+
We also provide major version tags to make it easier to always use the latest release of a major version. For example, you can use `step-security/git-auto-commit-action@v7` to always use the latest release of the current major version.
513
528
(More information about this [here](https://help.github.com/en/actions/building-actions/about-actions#versioning-your-action).)
_log "error" "Repository is in detached HEAD state. Please make sure you check out a branch. Adjust the `ref` input accordingly.";
124
-
exit 1;
113
+
_log "warning" "Repository is in a detached HEAD state. git-auto-commit will likely handle this automatically. To avoid it, check out a branch using the ref option in actions/checkout.";
125
114
else
126
115
_log "debug" "Repository is on a branch.";
127
116
fi
128
117
}
129
118
119
+
_switch_to_branch() {
120
+
echo "INPUT_BRANCH value: $INPUT_BRANCH";
121
+
122
+
# Fetch remote to make sure that repo can be switched to the right branch.
123
+
if "$INPUT_SKIP_FETCH"; then
124
+
_log "debug" "git-fetch will not be executed.";
125
+
else
126
+
_log "debug" "git-fetch will be executed.";
127
+
git fetch --depth=1;
128
+
fi
129
+
130
+
# If `skip_checkout`-input is true, skip the entire checkout step.
131
+
if "$INPUT_SKIP_CHECKOUT"; then
132
+
_log "debug" "git-checkout will not be executed.";
133
+
else
134
+
_log "debug" "git-checkout will be executed.";
135
+
# Create new local branch if `create_branch`-input is true
0 commit comments