Skip to content

Commit 87526a8

Browse files
Merge pull request #50 from stefanzweifel/feature/tag-commit
Feature: Tag commit created by the Action
2 parents 956a474 + 844c808 commit 87526a8

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ Add the following step at the end of your job.
3838
commit_user_name: My GitHub Actions Bot
3939
commit_user_email: my-github-actions-bot@example.org
4040
commit_author: Author <actions@gitub.com>
41+
42+
# Optional tag message. Will create and push a new tag to the remote repository
43+
tagging_message: 'v1.0.0'
4144
```
4245
4346
The Action will only commit files back, if changes are available. The resulting commit **will not trigger** another GitHub Actions Workflow run!

action.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ inputs:
3434
description: Value used for the commit author. Defaults to the username of whoever triggered this workflow run.
3535
required: false
3636
default: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
37+
tagging_message:
38+
description: Message used to create a new git tag with the commit. Keep this empty, if no tag should be created.
39+
required: false
40+
default: ''
3741

3842
outputs:
3943
changes_detected:

entrypoint.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ _main() {
1717

1818
_local_commit
1919

20+
_tag_commit
21+
2022
_push_to_github
2123
else
2224

@@ -59,12 +61,21 @@ _local_commit() {
5961
git commit -m "$INPUT_COMMIT_MESSAGE" --author="$INPUT_COMMIT_AUTHOR" ${INPUT_COMMIT_OPTIONS:+"$INPUT_COMMIT_OPTIONS"}
6062
}
6163

64+
_tag_commit() {
65+
echo "INPUT_TAGGING_MESSAGE: ${INPUT_TAGGING_MESSAGE}"
66+
67+
if [ -n "$INPUT_TAGGING_MESSAGE" ]
68+
then
69+
git tag -a "$INPUT_TAGGING_MESSAGE" -m "$INPUT_TAGGING_MESSAGE"
70+
fi
71+
}
72+
6273
_push_to_github() {
6374
if [ -z "$INPUT_BRANCH" ]
6475
then
65-
git push origin
76+
git push origin --tags
6677
else
67-
git push --set-upstream origin "HEAD:$INPUT_BRANCH"
78+
git push --set-upstream origin "HEAD:$INPUT_BRANCH" --tags
6879
fi
6980
}
7081

0 commit comments

Comments
 (0)