Added functionality to be able to set and push git tag

This commit is contained in:
Magnus Spånggård 2022-04-20 11:42:37 +02:00
parent ac0bb2c8f9
commit 6404b153ed
2 changed files with 13 additions and 0 deletions

View File

@ -48,6 +48,9 @@ inputs:
description: '[Optional] The directory to wipe and replace in the target repository'
default: ''
required: false
commit-tag:
description: '[Optional] The tag that should be applied to the commit'
required: false
runs:
using: docker
@ -64,6 +67,7 @@ runs:
- '${{ inputs.target-branch }}'
- '${{ inputs.commit-message }}'
- '${{ inputs.target-directory }}'
- '${{ inputs.commit-tag }}'
branding:
icon: git-commit
color: green

View File

@ -15,6 +15,7 @@ DESTINATION_REPOSITORY_USERNAME="${8}"
TARGET_BRANCH="${9}"
COMMIT_MESSAGE="${10}"
TARGET_DIRECTORY="${11}"
COMMIT_TAG="${12}"
if [ -z "$DESTINATION_REPOSITORY_USERNAME" ]
then
@ -118,3 +119,11 @@ git diff-index --quiet HEAD || git commit --message "$COMMIT_MESSAGE"
echo "[+] Pushing git commit"
# --set-upstream: sets de branch when pushing to a branch that does not exist
git push "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --set-upstream "$TARGET_BRANCH"
# Tag commit and push
if [ -v "$COMMIT_TAG" ]
then
echo "[+] git tag"
git tag $COMMIT_TAG
git push "https://$USER_NAME:$API_TOKEN_GITHUB@$GITHUB_SERVER/$DESTINATION_REPOSITORY_USERNAME/$DESTINATION_REPOSITORY_NAME.git" --tags
fi