8 Commits

4 changed files with 10 additions and 12 deletions

View File

@@ -21,10 +21,7 @@ jobs:
uses: akkuman/gitea-release-action@${{ vars.ACTION_RELEASE_VERSION }}
with:
tag_name: "v${{ needs.version.outputs.version }}"
test:
name: "CD > 清理舊版成品"
runs-on: ubuntu
needs: release
steps:
- name: 清理舊版成品
uses: https://gitea.jsc.idv.tw/actions/cleanup-release@${{ vars.ACTION_CLEANUP_RELEASE_VERSION }}
- name: 清理成品
uses: https://gitea.jsc.idv.tw/actions/cleanup-release@${{ vars.ACTION_CLEANUP_RELEASE_VERSION }}
with:
RUNNER_TOKEN: ${{ secrets.RUNNER_TOKEN }}

View File

@@ -1,8 +1,7 @@
FROM alpine:latest
# 更新並安裝必要的工具
RUN apk update \
&& apk add --no-cache bash curl jq
# 安裝必要的工具
RUN apk add --no-cache --no-check-certificate bash curl jq
COPY entrypoint.sh /entrypoint.sh

View File

@@ -2,6 +2,8 @@ name: 'CLEANUP OLD RELEASES'
description: '清理舊版成品'
author: 'Jeffery'
inputs:
RUNNER_TOKEN:
description: 'GitHub Runner Token'
KEEP_COUNT:
description: '保留的版本數量'
default: '2'
@@ -11,5 +13,5 @@ runs:
env:
GITEA_SERVER_URL: ${{ gitea.server_url }}
GITEA_REPOSITORY: ${{ gitea.repository }}
RUNNER_TOKEN: ${{ secrets.RUNNER_TOKEN }}
RUNNER_TOKEN: ${{ inputs.RUNNER_TOKEN || ${{ secrets.GITEA_TOKEN }} || secrets.RUNNER_TOKEN }}
KEEP_COUNT: ${{ inputs.KEEP_COUNT }}

View File

@@ -40,7 +40,7 @@ fi
# 計算成品數量並依照時間排序
RELEASE_JSON=$(echo "$RELEASE_JSON" | jq -e 'sort_by(.created_at) | reverse')
RELEASE_COUNT=$(echo "$RELEASE_JSON" | jq 'length')
RELEASE_COUNT=$(echo "$RELEASE_JSON" | jq 'length') && echo "RELEASE_COUNT=$RELEASE_COUNT"
# 檢查成品數量是否需要清除
[ $RELEASE_COUNT -le $KEEP_COUNT ] && exit 0