From ab529c7ebe8c1b5d24168866a4ed10ee0ba0a4ce Mon Sep 17 00:00:00 2001 From: Skydust Date: Tue, 1 Apr 2025 10:01:13 +0200 Subject: [PATCH] first commit --- .gitignore | 1 + README.md | 2 ++ action.yml | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 action.yml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..70abf74 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# update-publish-tag + diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..8e9f06a --- /dev/null +++ b/action.yml @@ -0,0 +1,40 @@ +name: Update publish tag +description: Moves the corresponding tag to the current commit +author: Skydust + +inputs: + tag: + description: The tag to create/move + required: false + default: "production" + token: + description: 'A Gitea PAT' + default: "${{ secrets.CI_TOKEN }}" + required: false + +runs: + using: composite + steps: + - name: Moving/Creating tag + run: | + TAG_TO_CREATE="${{ inputs.tag }}" + + git fetch origin tag "${TAG_TO_CREATE}" || NO_TAG_ON_REPO=yes + + if git tag --points-at HEAD | grep -q "^${TAG_TO_CREATE}"; then + log_info "$(green)${TAG_TO_CREATE} already on current commit" + exit 0 + fi + + if [[ -n "${NO_TAG_ON_REPO}" ]]; then + log_info "$(yellow)No ${TAG_TO_CREATE} tag on repo" + else + git push origin --delete "${TAG_TO_CREATE}" + git tag -d "${TAG_TO_CREATE}" + log_info "$(yellow)Removed ${TAG_TO_CREATE} tag from repo" + fi + + git tag "${TAG_TO_CREATE}" HEAD + git push origin "${TAG_TO_CREATE}" --force + log_info "$(green)${TAG_TO_CREATE} created successfully" + log_info "If you see old ones on fetch, use $(yellow)git config --global fetch.pruneTags true"