mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2025-08-03 09:06:08 +08:00
Compare commits
20 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
94c72aa7c5 | ||
|
87526a8aa1 | ||
|
844c808726 | ||
|
ce08dda6b3 | ||
|
0ad4c8ce73 | ||
|
3387b2f267 | ||
|
d4a53f1779 | ||
|
956a47433b | ||
|
f866b2a854 | ||
|
8744cc88ef | ||
|
57bbd38e56 | ||
|
eef5f33ea3 | ||
|
25e6f0b17d | ||
|
ae885f5d8c | ||
|
33e8fd937f | ||
|
404d2015f4 | ||
|
cd0530ad7a | ||
|
2a957f5c41 | ||
|
7e64e614a1 | ||
|
c887fa4a07 |
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\""
|
12
CHANGELOG.md
12
CHANGELOG.md
@@ -4,14 +4,22 @@ 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.0...HEAD)
|
||||||
|
|
||||||
> TBD
|
> TBD
|
||||||
|
|
||||||
|
|
||||||
|
## [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)
|
||||||
|
|
||||||
|
|
||||||
## [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
|
||||||
|
|
||||||
|
21
README.md
21
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.0
|
||||||
with:
|
with:
|
||||||
commit_message: Apply automatic changes
|
commit_message: Apply automatic changes
|
||||||
|
|
||||||
@@ -38,12 +38,15 @@ Add the following step at the end of your job.
|
|||||||
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@gitub.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.0
|
||||||
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.0
|
||||||
with:
|
with:
|
||||||
commit_message: Apply php-cs-fixer changes
|
commit_message: Apply php-cs-fixer changes
|
||||||
```
|
```
|
||||||
@@ -103,6 +106,11 @@ 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
|
||||||
@@ -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.0
|
||||||
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,21 @@ _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"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
_push_to_github() {
|
_push_to_github() {
|
||||||
if [ -z "$INPUT_BRANCH" ]
|
if [ -z "$INPUT_BRANCH" ]
|
||||||
then
|
then
|
||||||
git push origin
|
git push origin --tags
|
||||||
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