mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-03 00:56:08 +08:00
Compare commits
36 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
dd055f6225 | ||
|
55734408b7 | ||
|
d317154f77 | ||
|
36489f4cb5 | ||
|
2530046e72 | ||
|
172c2a2fc3 | ||
|
480e111bf8 | ||
|
7659782c71 | ||
|
026f88c27c | ||
|
f73d11d461 | ||
|
2b6b90e8f1 | ||
|
e1770ec52b | ||
|
0453bb1c25 | ||
|
da55e4a0cf | ||
|
b1833bd054 | ||
|
6dfda22dd6 | ||
|
94c72aa7c5 | ||
|
87526a8aa1 | ||
|
844c808726 | ||
|
ce08dda6b3 | ||
|
0ad4c8ce73 | ||
|
3387b2f267 | ||
|
d4a53f1779 | ||
|
956a47433b | ||
|
f866b2a854 | ||
|
8744cc88ef | ||
|
57bbd38e56 | ||
|
eef5f33ea3 | ||
|
25e6f0b17d | ||
|
ae885f5d8c | ||
|
33e8fd937f | ||
|
404d2015f4 | ||
|
cd0530ad7a | ||
|
2a957f5c41 | ||
|
7e64e614a1 | ||
|
c887fa4a07 |
2
.github/workflows/continuous-deployment.yml
vendored
2
.github/workflows/continuous-deployment.yml
vendored
@@ -25,5 +25,7 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
draft: false
|
draft: false
|
||||||
prerelease: false
|
prerelease: false
|
||||||
|
body: |
|
||||||
|
See [Changelog](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/CHANGELOG.md) for details.
|
||||||
release_name: "${{ steps.determine-tag.outputs.tag }}"
|
release_name: "${{ steps.determine-tag.outputs.tag }}"
|
||||||
tag_name: "${{ steps.determine-tag.outputs.tag }}"
|
tag_name: "${{ steps.determine-tag.outputs.tag }}"
|
||||||
|
22
.github/workflows/git-auto-commit.yml
vendored
Normal file
22
.github/workflows/git-auto-commit.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
name: git-auto-commit
|
||||||
|
|
||||||
|
on: push
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
git-auto-commit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Use git-auto-commit-action
|
||||||
|
id: "auto-commit-action"
|
||||||
|
uses: ./
|
||||||
|
|
||||||
|
- name: "no changes detected"
|
||||||
|
if: steps.auto-commit-action.outputs.changes_detected == false
|
||||||
|
run: "echo \"No changes detected\""
|
||||||
|
|
||||||
|
- name: "changes detected"
|
||||||
|
if: steps.auto-commit-action.outputs.changes_detected == true
|
||||||
|
run: "echo \"Changes detected\""
|
22
CHANGELOG.md
22
CHANGELOG.md
@@ -4,14 +4,30 @@ All notable changes to this project will be documented in this file.
|
|||||||
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
|
||||||
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.0.0...HEAD)
|
## [Unreleased](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.2...HEAD)
|
||||||
|
|
||||||
|
## [v4.1.2](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.1...v4.1.2) - 2020-04-03
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fix Issue with `changes_detected`-output [#57](https://github.com/stefanzweifel/git-auto-commit-action/pull/57)
|
||||||
|
|
||||||
|
## [v4.1.1](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.1.0...v4.1.1) - 2020-03-14
|
||||||
|
|
||||||
|
### Fixes
|
||||||
|
- Fix issue where commit has not been pushed to remote repository, when no `branch`-option has been given [#54](https://github.com/stefanzweifel/git-auto-commit-action/pull/54)
|
||||||
|
|
||||||
|
|
||||||
|
## [v4.1.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v4.0.0...v4.1.0) - 2020-03-05
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Add `changes_detected` output [#49](https://github.com/stefanzweifel/git-auto-commit-action/pull/49), [#46](https://github.com/stefanzweifel/git-auto-commit-action/issues/46)
|
||||||
|
- Add `tagging_message` input option to create and push tags [#50](https://github.com/stefanzweifel/git-auto-commit-action/pull/50), [#47](https://github.com/stefanzweifel/git-auto-commit-action/issues/47)
|
||||||
|
|
||||||
> TBD
|
|
||||||
|
|
||||||
## [v4.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...v4.0.0) - 2020-02-24
|
## [v4.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v3.0.0...v4.0.0) - 2020-02-24
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- Switch Action to use `node12`-environment instead of `docker`.
|
- Switch Action to use `node12`-environment instead of `docker`. [#45](https://github.com/stefanzweifel/git-auto-commit-action/pull/45)
|
||||||
|
|
||||||
## [v3.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...v3.0.0) - 2020-02-06
|
## [v3.0.0](https://github.com/stefanzweifel/git-auto-commit-action/compare/v2.5.0...v3.0.0) - 2020-02-06
|
||||||
|
|
||||||
|
27
README.md
27
README.md
@@ -17,7 +17,7 @@ This Action has been inspired and adapted from the [auto-commit](https://github.
|
|||||||
Add the following step at the end of your job.
|
Add the following step at the end of your job.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.1.2
|
||||||
with:
|
with:
|
||||||
commit_message: Apply automatic changes
|
commit_message: Apply automatic changes
|
||||||
|
|
||||||
@@ -37,13 +37,16 @@ Add the following step at the end of your job.
|
|||||||
# Optional commit user and author settings
|
# Optional commit user and author settings
|
||||||
commit_user_name: My GitHub Actions Bot
|
commit_user_name: My GitHub Actions Bot
|
||||||
commit_user_email: my-github-actions-bot@example.org
|
commit_user_email: my-github-actions-bot@example.org
|
||||||
commit_author: Author <actions@gitub.com>
|
commit_author: Author <actions@github.com>
|
||||||
|
|
||||||
|
# Optional tag message. Will create and push a new tag to the remote repository
|
||||||
|
tagging_message: 'v1.0.0'
|
||||||
```
|
```
|
||||||
|
|
||||||
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
|
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!
|
||||||
|
|
||||||
We recommend to use this Action in Workflows, which listen to the `pull_request` event. You can then use the option `branch: ${{ github.head_ref }}` to set up the branch name correctly.
|
We recommend to use this Action in Workflows, which listen to the `pull_request` event. You can then use the option `branch: ${{ github.head_ref }}` to set up the branch name correctly.
|
||||||
If you don't pass a branch name, the Action will try to push the commit to a branch with the same name, as with wich the repo has been checked out.
|
If you don't pass a branch name, the Action will try to push the commit to a branch with the same name, as with which the repo has been checked out.
|
||||||
|
|
||||||
## Example Usage
|
## Example Usage
|
||||||
|
|
||||||
@@ -71,7 +74,7 @@ jobs:
|
|||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.1.2
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
branch: ${{ github.head_ref }}
|
branch: ${{ github.head_ref }}
|
||||||
@@ -94,7 +97,7 @@ jobs:
|
|||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.1.2
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
```
|
```
|
||||||
@@ -103,20 +106,25 @@ jobs:
|
|||||||
|
|
||||||
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
|
Checkout [`action.yml`](https://github.com/stefanzweifel/git-auto-commit-action/blob/master/action.yml) for a full list of supported inputs.
|
||||||
|
|
||||||
|
## Outputs
|
||||||
|
You can use these outputs to trigger other Actions in your Workflow run based on the result of `git-auto-commit-action`.
|
||||||
|
|
||||||
|
- `changes_detected`: Returns either "true" or "false" if the repository was dirty and files have changed.
|
||||||
|
|
||||||
## Troubleshooting
|
## Troubleshooting
|
||||||
|
|
||||||
### Can't push commit to repository
|
### Can't push commit to repository
|
||||||
If your Workflow can't push the commit to the repository because of authentication issues, please update your Workflow configuration and usage of [`actions/checkout`](https://github.com/actions/checkout#usage). (Updating the `token` value with a Personal Access Token should fix your issues)
|
If your Workflow can't push the commit to the repository because of authentication issues, please update your Workflow configuration and usage of [`actions/checkout`](https://github.com/actions/checkout#usage). (Updating the `token` value with a Personal Access Token should fix your issues)
|
||||||
|
|
||||||
### Commit of this Action does not trigger a new Workflow run
|
### Commit of this Action does not trigger a new Workflow run
|
||||||
As mentioned in the [Usage](#Usage) section, the commit created by this Action **will not trigger** a new Workflow run automatically.
|
As mentioned in the [Usage](#Usage) section, the commit created by this Action **will not trigger** a new Workflow run automatically.
|
||||||
|
|
||||||
This is due to limitations set up by GitHub:
|
This is due to limitations set up by GitHub:
|
||||||
|
|
||||||
> An action in a workflow run can't trigger a new workflow run. For example, if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
|
> An action in a workflow run can't trigger a new workflow run. For example, if an action pushes code using the repository's GITHUB_TOKEN, a new workflow will not run even when the repository contains a workflow configured to run when push events occur.
|
||||||
[Source](https://help.github.com/en/actions/reference/events-that-trigger-workflows)
|
[Source](https://help.github.com/en/actions/reference/events-that-trigger-workflows)
|
||||||
|
|
||||||
You can change this by creating a new [Pesonal Access Token (PAT)](https://github.com/settings/tokens/new), 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.
|
You can change this by creating a new [Personal Access Token (PAT)](https://github.com/settings/tokens/new), 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.
|
||||||
|
|
||||||
#### Example Workflow
|
#### Example Workflow
|
||||||
|
|
||||||
@@ -131,12 +139,13 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
token: ${{ secrets.PAT_TOKEN }}
|
with:
|
||||||
|
token: ${{ secrets.PAT_TOKEN }}
|
||||||
|
|
||||||
- name: Run php-cs-fixer
|
- name: Run php-cs-fixer
|
||||||
uses: docker://oskarstark/php-cs-fixer-ga
|
uses: docker://oskarstark/php-cs-fixer-ga
|
||||||
|
|
||||||
- uses: stefanzweifel/git-auto-commit-action@v4.0.0
|
- uses: stefanzweifel/git-auto-commit-action@v4.1.2
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
```
|
```
|
||||||
|
@@ -34,6 +34,14 @@ inputs:
|
|||||||
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
|
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
|
||||||
|
tagging_message:
|
||||||
|
description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created.
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
|
|
||||||
|
outputs:
|
||||||
|
changes_detected:
|
||||||
|
description: Value is "true", if the repository was dirty and file changes have been detected. Value is "false", if no changes have been detected.
|
||||||
|
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
|
@@ -7,6 +7,8 @@ _main() {
|
|||||||
|
|
||||||
if _git_is_dirty; then
|
if _git_is_dirty; then
|
||||||
|
|
||||||
|
echo "::set-output name=changes_detected::true"
|
||||||
|
|
||||||
_setup_git
|
_setup_git
|
||||||
|
|
||||||
_switch_to_branch
|
_switch_to_branch
|
||||||
@@ -15,8 +17,13 @@ _main() {
|
|||||||
|
|
||||||
_local_commit
|
_local_commit
|
||||||
|
|
||||||
|
_tag_commit
|
||||||
|
|
||||||
_push_to_github
|
_push_to_github
|
||||||
else
|
else
|
||||||
|
|
||||||
|
echo "::set-output name=changes_detected::false"
|
||||||
|
|
||||||
echo "Working tree clean. Nothing to commit."
|
echo "Working tree clean. Nothing to commit."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -54,12 +61,30 @@ _local_commit() {
|
|||||||
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_tag_commit() {
|
||||||
|
echo "INPUT_TAGGING_MESSAGE: ${INPUT_TAGGING_MESSAGE}"
|
||||||
|
|
||||||
|
if [ -n "$INPUT_TAGGING_MESSAGE" ]
|
||||||
|
then
|
||||||
|
git tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"
|
||||||
|
else
|
||||||
|
echo " No tagging message supplied. No tag will be added."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_push_to_github() {
|
_push_to_github() {
|
||||||
if [ -z "$INPUT_BRANCH" ]
|
if [ -z "$INPUT_BRANCH" ]
|
||||||
then
|
then
|
||||||
git push origin
|
# Only add `--tags` option, if `$INPUT_TAGGING_MESSAGE` is set
|
||||||
|
if [ -n "$INPUT_TAGGING_MESSAGE" ]
|
||||||
|
then
|
||||||
|
git push origin --tags
|
||||||
|
else
|
||||||
|
git push origin
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
|
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user