mirror of
https://github.com/stefanzweifel/git-auto-commit-action.git
synced 2024-12-06 02:09:04 +00:00
Merge pull request #50 from stefanzweifel/feature/tag-commit
Feature: Tag commit created by the Action
This commit is contained in:
commit
87526a8aa1
@ -38,6 +38,9 @@ Add the following step at the end of your job.
|
||||
commit_user_name: My GitHub Actions Bot
|
||||
commit_user_email: my-github-actions-bot@example.org
|
||||
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!
|
||||
|
@ -34,6 +34,10 @@ inputs:
|
||||
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
|
||||
required: false
|
||||
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:
|
||||
|
@ -17,6 +17,8 @@ _main() {
|
||||
|
||||
_local_commit
|
||||
|
||||
_tag_commit
|
||||
|
||||
_push_to_github
|
||||
else
|
||||
|
||||
@ -59,12 +61,21 @@ _local_commit() {
|
||||
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() {
|
||||
if [ -z "$INPUT_BRANCH" ]
|
||||
then
|
||||
git push origin
|
||||
git push origin --tags
|
||||
else
|
||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
|
||||
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags
|
||||
fi
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user