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
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the commit back to GitHub.
10
+
A GitHub Action to detect changed files during a Workflow run and to commit and push them back to the GitHub repository.
11
11
By default, the commit is made in the name of "GitHub Actions" and co-authored by the user that made the last commit.
12
12
13
-
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit
14
-
)-Action of the Canadian Digital Service and this [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action by Eric Johnson.
15
-
16
13
If you want to learn more how this Action works under the hood, check out [this article](https://michaelheap.com/git-auto-commit/) by Michael Heap.
17
14
18
15
## Usage
@@ -23,8 +20,7 @@ Add the following step at the end of your job, after other steps that might add
23
20
- uses: stefanzweifel/git-auto-commit-action@v4
24
21
```
25
22
26
-
27
-
This is a more extended example with all possible options.
23
+
The following is an extended example with all possible options available for this Action.
28
24
29
25
```yaml
30
26
- uses: stefanzweifel/git-auto-commit-action@v4
@@ -84,7 +80,7 @@ This is a more extended example with all possible options.
84
80
disable_globbing: true
85
81
```
86
82
87
-
## Example
83
+
## Example Workflow
88
84
89
85
In this example, we're running `php-cs-fixer` in a PHP project to fix the codestyle automatically, then commit possible changed files back to the repository.
90
86
@@ -154,7 +150,7 @@ In non-`push` events, such as `pull_request`, make sure to specify the `ref` to
154
150
155
151
You have to do this to avoid that the `checkout`-Action clones your repository in a detached state.
156
152
157
-
### Commits of this Action do not trigger new Workflow runs
153
+
### Commits made by this Action do not trigger new Workflow runs
158
154
159
155
The resulting commit **will not trigger** another GitHub Actions Workflow run.
160
156
This is due to [limitations set by GitHub](https://help.github.com/en/actions/reference/events-that-trigger-workflows#triggering-new-workflows-using-a-personal-access-token).
@@ -222,7 +218,7 @@ Here's how the Pull Request will look like:
222
218

223
219
224
220
225
-
As you can see, your contributors have to go through hoops to make this work. **For Workflows which runter linters and fixers (like the example above) we recommend running them when a push happens on the `master`-branch.**
221
+
As you can see, your contributors have to go through hoops to make this work. **For Workflows which run linters and fixers (like the example above) we recommend running them when a push happens on the `main`-branch.**
226
222
227
223
228
224
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/).
@@ -235,7 +231,7 @@ See [this announcement from GitHub](https://github.blog/2020-08-03-github-action
235
231
236
232
### Signing Commits & Other Git Command Line Options
237
233
238
-
Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regulary
234
+
Using command lines options needs to be done manually for each workflow which you require the option enabled. So for example signing commits requires you to import the gpg signature each and every time. The following list of actions are worth checking out if you need to automate these tasks regulary.
239
235
240
236
- [Import GPG Signature](https://github.com/crazy-max/ghaction-import-gpg) (Suggested by [TGTGamer](https://github.com/tgtgamer))
241
237
@@ -254,18 +250,9 @@ Updating the `token` value with a Personal Access Token should fix your issues.
254
250
255
251
### Push to protected branches
256
252
257
-
If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to do the following changes to your Workflow for the Action to work properly.
258
-
259
-
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.
260
-
261
-
```yaml
262
-
- uses: stefanzweifel/git-auto-commit-action@v4
263
-
with:
264
-
commit_message: Apply php-cs-fixer changes
265
-
push_options: --force
266
-
```
253
+
If your repository uses [protected branches](https://help.github.com/en/github/administering-a-repository/configuring-protected-branches) you have to make some changes to your Workflow for the Action to work properly: You need a Personal Access Token and you either have to allow force pushes or the Personal Acess Token needs to belong to an Administrator.
267
254
268
-
In addition, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
255
+
First, you have to create a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new),
269
256
store the token as a secret in your repository and pass the new token to the [`actions/checkout`](https://github.com/actions/checkout#usage) Action step.
270
257
271
258
```yaml
@@ -275,7 +262,17 @@ store the token as a secret in your repository and pass the new token to the [`a
275
262
```
276
263
You can learn more about Personal Access Token in the [GitHub documentation](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token).
277
264
278
-
Note: If you're working in an organisation and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.
265
+
**Note:** If you're working in an organisation and you don't want to create the PAT from your personal account, we recommend using a bot-account for such tokens.
266
+
267
+
268
+
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.
269
+
270
+
```yaml
271
+
- uses: stefanzweifel/git-auto-commit-action@v4
272
+
with:
273
+
commit_message: Apply php-cs-fixer changes
274
+
push_options: --force
275
+
```
279
276
280
277
### No new workflows are triggered by the commit of this action
281
278
@@ -309,6 +306,9 @@ We also provide major version tags to make it easier to always use the latest re
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit
310
+
)-Action of the Canadian Digital Service and this [commit](https://github.com/elstudio/actions-js-build/blob/41d604d6e73d632e22eac40df8cc69b5added04b/commit/entrypoint.sh)-Action by Eric Johnson.
311
+
312
312
## License
313
313
314
314
This project is licensed under the MIT License - see the [LICENSE](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/LICENSE) file for details.
0 commit comments