From ea8b72ce8f2c6c174ae6d1b6e85c5bfbb0e12dcc Mon Sep 17 00:00:00 2001 From: Jeffery Date: Fri, 20 Mar 2026 14:18:53 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=94=B9=E6=88=90=20docker=20action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 11 +++++++++++ action.yml | 29 ++--------------------------- entrypoint.sh | 16 ++++++++++++++++ 3 files changed, 29 insertions(+), 27 deletions(-) create mode 100644 Dockerfile create mode 100644 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..08b23e1 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,11 @@ +FROM alpine:3.21 + +RUN apk add --no-cache bash curl jq + +COPY cleanup-releases.sh /cleanup-releases.sh +COPY cleanup-images.sh /cleanup-images.sh +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /cleanup-releases.sh /cleanup-images.sh /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] diff --git a/action.yml b/action.yml index 2cb25cf..9aa3f1b 100644 --- a/action.yml +++ b/action.yml @@ -23,30 +23,5 @@ inputs: required: false default: 'false' runs: - using: 'composite' - steps: - - name: 清理舊版本 - id: cleanup - shell: bash - run: | - chmod +x "${{ github.action_path }}/cleanup-releases.sh" - "${{ github.action_path }}/cleanup-releases.sh" \ - "${{ inputs.gitea-server }}" \ - "${{ inputs.repository }}" \ - "${{ inputs.token }}" \ - "${{ inputs.keep-count }}" \ - "${{ inputs.dry-run }}" - - - name: 清理舊映像 - id: cleanup-images - if: inputs.package-name != '' - shell: bash - run: | - chmod +x "${{ github.action_path }}/cleanup-images.sh" - "${{ github.action_path }}/cleanup-images.sh" \ - "${{ inputs.gitea-server }}" \ - "${{ inputs.repository }}" \ - "${{ inputs.package-name }}" \ - "${{ inputs.token }}" \ - "${{ inputs.keep-count }}" \ - "${{ inputs.dry-run }}" + using: 'docker' + image: 'Dockerfile' diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..c781874 --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,16 @@ +#!/bin/bash + +set -euo pipefail + +GITEA_SERVER="${INPUT_GITEA_SERVER}" +REPOSITORY="${INPUT_REPOSITORY}" +PACKAGE_NAME="${INPUT_PACKAGE_NAME:-}" +TOKEN="${INPUT_TOKEN}" +KEEP_COUNT="${INPUT_KEEP_COUNT:-2}" +DRY_RUN="${INPUT_DRY_RUN:-false}" + +/cleanup-releases.sh "$GITEA_SERVER" "$REPOSITORY" "$TOKEN" "$KEEP_COUNT" "$DRY_RUN" + +if [[ -n "$PACKAGE_NAME" ]]; then + /cleanup-images.sh "$GITEA_SERVER" "$REPOSITORY" "$PACKAGE_NAME" "$TOKEN" "$KEEP_COUNT" "$DRY_RUN" +fi -- 2.48.1