From 9d8eaf5580ebb7397913ba6c53612247ad41dd9b Mon Sep 17 00:00:00 2001 From: firerui <163150002+firerui@users.noreply.github.com> Date: Tue, 3 Sep 2024 14:56:52 +0800 Subject: [PATCH] Update docker-image-to-release.yml --- .github/workflows/docker-image-to-release.yml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/docker-image-to-release.yml b/.github/workflows/docker-image-to-release.yml index 5df1f06..ba350a7 100644 --- a/.github/workflows/docker-image-to-release.yml +++ b/.github/workflows/docker-image-to-release.yml @@ -26,12 +26,19 @@ jobs: - name: Checkout code uses: actions/checkout@v3 - - name: actions/checkout@v3 - uses: Nats-ji/delete-old-releases@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - keep-count: 1 - keep-old-minor-releases: true + - name: Delete Previous Release + run: | + # 获取最新的release的tag名 + PREVIOUS_TAG=$(curl --silent "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/latest" | jq -r .tag_name) + if [ "$PREVIOUS_TAG" != "null" ]; then + # 删除release + curl -X DELETE -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/$GITHUB_REPOSITORY/releases/tags/$PREVIOUS_TAG" + echo "Previous release $PREVIOUS_TAG deleted." + else + echo "No previous release found." + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v2