From a3dadea932df6f8904546c09c6502717cb8df8ea Mon Sep 17 00:00:00 2001 From: Dan Haman Date: Mon, 28 Sep 2026 00:57:46 +0300 Subject: [PATCH] #1 : Publish generic package to gitea + force flag handling + test case for force --- .gitea/workflows/test.yaml | 12 +++++++++++- publish/action.yaml | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/test.yaml b/.gitea/workflows/test.yaml index 7190ac8..5873a2a 100644 --- a/.gitea/workflows/test.yaml +++ b/.gitea/workflows/test.yaml @@ -17,4 +17,14 @@ jobs: file: text.txt package: a-proper-test-package version: master - force: false \ No newline at end of file + - uses: https://source.vague.tech/open-vague/ci-actions/publish@feature/1-publish + with: + file: text.txt + package: a-proper-test-package + version: master + force: true + - uses: https://source.vague.tech/open-vague/ci-actions/publish@feature/1-publish + with: + file: text.txt + package: a-proper-test-package + version: master \ No newline at end of file diff --git a/publish/action.yaml b/publish/action.yaml index 2595058..a226dc7 100644 --- a/publish/action.yaml +++ b/publish/action.yaml @@ -14,12 +14,30 @@ inputs: force: description: force package replacement keeping the same version required: false + default: "false" runs: using: composite steps: - shell: bash run: | + set -euo pipefail + if [[ "${INPUT_FORCE,,}" == "true" ]]; then + status="$( + curl --silent --show-error --output /dev/null --write-out '%{http_code}' \ + --user "acti-bot:${ACTI_BOT_TOKEN}" \ + --request DELETE \ + "${{ gitea.server_url }}/api/packages/${{ gitea.repository_owner }}/generic/${{ inputs.package }}/${{ inputs.version }}" + )" + + case "$status" in + 204|404) ;; + *) + echo "Failed to delete existing package version (HTTP ${status})" >&2 + exit 1 + ;; + esac + fi curl --fail-with-body \ --user "acti-bot:${ACTI_BOT_TOKEN}" \ --upload-file ${{ inputs.file }} \