From f554ab96f1efbe34c38ec2dcd83d4332b8b159d9 Mon Sep 17 00:00:00 2001 From: Scott Leggett Date: Fri, 24 May 2024 21:31:31 +0800 Subject: [PATCH] feat: add the option for the action to be read-only --- action.yaml | 11 +++++++++-- entrypoint.sh | 10 +++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/action.yaml b/action.yaml index 72af106..72a484d 100644 --- a/action.yaml +++ b/action.yaml @@ -1,10 +1,17 @@ name: Conventional Commits Versioner Action description: Automatically tag a new version based on the commit messages of commits since the last tag. +inputs: + write-tag: + description: 'If true, and ccv determines that a new version is required, the action will automatically write the new version tag to the repository.' + required: false + default: 'true' outputs: - new_tag: + new-tag: description: Either "true" or "false" depending on whether a new tag was pushed. - new_tag_version: + new-tag-version: description: The new version that was tagged. This will only be set if new_tag=true. runs: using: docker image: Dockerfile + args: + - ${{ inputs.write-tag }} diff --git a/entrypoint.sh b/entrypoint.sh index 807e414..030210f 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,7 @@ #!/bin/sh set -eu +# if the first argument to the script is "true", it will push a tag to the repository. +WRITE_TAG="$1" # https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action#accessing-files-created-by-a-container-action cd /github/workspace # if the ccv tag exists, just exit @@ -8,7 +10,9 @@ if [ "$(git tag -l "$(ccv)")" ]; then exit fi # if it doesn't, tag and push -git tag "$(ccv)" -git push --tags +if [ "$WRITE_TAG" = "true" ]; then + git tag "$(ccv)" + git push --tags +fi echo "new_tag=true" >>"$GITHUB_OUTPUT" -echo "new_tag_version=$(git tag --points-at HEAD)" >>"$GITHUB_OUTPUT" +echo "new_tag_version=$(ccv)" >>"$GITHUB_OUTPUT"