diff --git a/README.md b/README.md index 265cc5c..af6dc24 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ Add a step like this to your workflow: # Default: '' remove: "./dir/old_file.js" + # Name of the tag to add to the new commit. Use an empty string to disable tagging. + # Default: '' + tag: "v1.0.0" + env: # This is necessary in order to push a commit to the repo GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Leave this line unchanged diff --git a/action.yml b/action.yml index 32074c0..7242b96 100644 --- a/action.yml +++ b/action.yml @@ -31,6 +31,10 @@ inputs: description: Arguments for the git rm command required: false default: "" + tag: + description: The name of the tag to add to the new commit + required: false + default: "" runs: using: node12 diff --git a/lib/entrypoint.sh b/lib/entrypoint.sh index db6963f..5295b14 100755 --- a/lib/entrypoint.sh +++ b/lib/entrypoint.sh @@ -31,6 +31,10 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +tag() { + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi +} + # This is needed to make the check work for untracked files echo "Staging files..." add @@ -68,8 +72,11 @@ if ! git diff --cached --quiet --exit-code; then echo "Creating commit..." git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + echo "Tagging commit..." + tag + echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" --tags echo "::endgroup::" echo "Task completed." diff --git a/src/entrypoint.sh b/src/entrypoint.sh index db6963f..5295b14 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -31,6 +31,10 @@ remove() { if [ -n "$INPUT_REMOVE" ]; then git rm $INPUT_REMOVE; fi } +tag() { + if [ -n "$INPUT_TAG" ]; then git tag $INPUT_TAG; fi +} + # This is needed to make the check work for untracked files echo "Staging files..." add @@ -68,8 +72,11 @@ if ! git diff --cached --quiet --exit-code; then echo "Creating commit..." git commit -m "$INPUT_MESSAGE" --author="$INPUT_AUTHOR_NAME <$INPUT_AUTHOR_EMAIL>" + echo "Tagging commit..." + tag + echo "Pushing to repo..." - git push --set-upstream origin "$INPUT_REF" + git push --set-upstream origin "$INPUT_REF" --tags echo "::endgroup::" echo "Task completed."