From 6404b153edbcd378883536983ec87f296eecf832 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Magnus=20Spa=CC=8Angga=CC=8Ard?= Date: Wed, 20 Apr 2022 11:42:37 +0200 Subject: [PATCH] Added functionality to be able to set and push git tag --- action.yml | 4 ++++ entrypoint.sh | 9 +++++++++ 2 files changed, 13 insertions(+) diff --git a/action.yml b/action.yml index 815415f..17f0e95 100644 --- a/action.yml +++ b/action.yml @@ -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 diff --git a/entrypoint.sh b/entrypoint.sh index 82ad593..ff12f87 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -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