Skip to content

Commit 81fa501

Browse files
Merge pull request #36 from stefanzweifel/refactor/remove-git-setup
Remove need for GITHUB_TOKEN
2 parents 1a9ba81 + ae384f9 commit 81fa501

File tree

3 files changed

+12
-57
lines changed

3 files changed

+12
-57
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
66

77
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...HEAD)
88

9-
> TBD
9+
### Removed
10+
- Remove the need of a GITHUB_TOKEN. Users now have to use `actions/checkout@v2` or higher [#36](https://github.com/stefanzweifel/git-auto-commit-action/pull/36)
11+
1012

1113
## [v2.5.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.4.0...v2.5.0) - 2019-12-18
1214

README.md

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
This GitHub Action automatically commits files which have been changed during a Workflow run and pushes the Commit back to GitHub.
44
The Committer is "GitHub Actions <actions@github.com>" and the Author of the Commit is "Your GitHub Username <github_username@users.noreply.github.com>.
55

6-
If no changes are available, the Actions does nothing.
6+
If no changes are detected, the Action does nothing.
77

88
This Action has been inspired and adapted from the [auto-commit](https://github.com/cds-snc/github-actions/tree/master/auto-commit
99
)-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.
1010

11-
*This action currently can't be used in conjunction with pull requests of forks. See [issue #25](https://github.com/stefanzweifel/git-auto-commit-action/issues/25) for more information.*
11+
*This Action currently can't be used in conjunction with pull requests of forks. See [issue #25](https://github.com/stefanzweifel/git-auto-commit-action/issues/25) for more information.*
1212

1313
## Usage
1414

15+
**Note:** This Action requires that you use `action/checkout@v2` or above to checkout your repository.
16+
1517
Add the following step at the end of your job.
1618

1719
```yaml
@@ -28,13 +30,8 @@ Add the following step at the end of your job.
2830

2931
# Optional repository path
3032
repository: .
31-
32-
env:
33-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3433
```
3534
36-
You **do not** have to create a new secret called `GITHUB_TOKEN` in your repository. `GITHUB_TOKEN` is a special token GitHub creates automatically during a Workflow run. (See [the documentation](https://help.github.com/en/articles/virtual-environments-for-github-actions#creating-and-using-secrets-encrypted-variables) for details)
37-
3835
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
3936
4037
It is recommended to use this Action in Workflows which listen to the `pull_request` event. If you want to use the Action on other events, you have to hardcode the value for `branch` as `github.head_ref` is only available in Pull Requests.
@@ -46,9 +43,6 @@ The most common use case for this, is when you're running a Linter or Code-Style
4643

4744
In this example I'm running `php-cs-fixer` in a PHP project.
4845

49-
50-
### Example with `actions/checkout@v2`
51-
5246
```yaml
5347
name: php-cs-fixer
5448
@@ -70,46 +64,16 @@ jobs:
7064
with:
7165
commit_message: Apply php-cs-fixer changes
7266
branch: ${{ github.head_ref }}
73-
env:
74-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75-
76-
```
77-
78-
### Example with `actions/checkout@v1`
79-
80-
```yaml
81-
name: php-cs-fixer
82-
83-
on:
84-
pull_request:
85-
86-
jobs:
87-
php-cs-fixer:
88-
runs-on: ubuntu-latest
89-
90-
steps:
91-
- uses: actions/checkout@v1
92-
with:
93-
fetch-depth: 1
94-
95-
- name: Run php-cs-fixer
96-
uses: docker://oskarstark/php-cs-fixer-ga
97-
98-
- name: Commit changed files
99-
uses: stefanzweifel/git-auto-commit-action@v2.5.0
100-
with:
101-
commit_message: Apply php-cs-fixer changes
102-
branch: ${{ github.head_ref }}
103-
file_pattern: src/\*.php
104-
env:
105-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106-
10767
```
10868

10969
### Inputs
11070

11171
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
11272

73+
## Troubleshooting
74+
75+
- If your Workflow can't push the commit to the repository because of authentication issues, please update your Workflow configuration and usage of [`ations/checkout`](https://github.com/actions/checkout#usage). (Updating the `token` value with a Personal Access Token should fix your issues)
76+
11377
## Known Issues
11478

11579
- GitHub currently prohibits Actions like this to push changes from a fork to the upstream repository. See [issue #25](https://github.com/stefanzweifel/git-auto-commit-action/issues/25) for more information.

entrypoint.sh

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,8 @@ _git_is_dirty() {
3131
[[ -n "$(git status -s)" ]]
3232
}
3333

34-
# Set up .netrc file with GitHub credentials
34+
# Set up git user configuration
3535
_setup_git ( ) {
36-
cat <<- EOF > $HOME/.netrc
37-
machine github.com
38-
login $GITHUB_ACTOR
39-
password $GITHUB_TOKEN
40-
41-
machine api.github.com
42-
login $GITHUB_ACTOR
43-
password $GITHUB_TOKEN
44-
EOF
45-
chmod 600 $HOME/.netrc
46-
4736
git config --global user.email "actions@github.com"
4837
git config --global user.name "GitHub Actions"
4938
}

0 commit comments

Comments
 (0)