Compare commits
2 Commits
ae8127d5c2
...
v0.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cd5480b334 | ||
|
|
ea8b72ce8f |
11
Dockerfile
Normal file
11
Dockerfile
Normal file
@@ -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"]
|
||||
36
action.yml
36
action.yml
@@ -23,30 +23,12 @@ 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'
|
||||
env:
|
||||
GITEA_SERVER: ${{ inputs.gitea-server }}
|
||||
REPOSITORY: ${{ inputs.repository }}
|
||||
PACKAGE_NAME: ${{ inputs.package-name }}
|
||||
TOKEN: ${{ inputs.token }}
|
||||
KEEP_COUNT: ${{ inputs.keep-count }}
|
||||
DRY_RUN: ${{ inputs.dry-run }}
|
||||
|
||||
21
entrypoint.sh
Normal file
21
entrypoint.sh
Normal file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
GITEA_SERVER="${GITEA_SERVER:-}"
|
||||
REPOSITORY="${REPOSITORY:-}"
|
||||
PACKAGE_NAME="${PACKAGE_NAME:-}"
|
||||
TOKEN="${TOKEN:-}"
|
||||
KEEP_COUNT="${KEEP_COUNT:-2}"
|
||||
DRY_RUN="${DRY_RUN:-false}"
|
||||
|
||||
if [[ -z "$GITEA_SERVER" ]] || [[ -z "$REPOSITORY" ]] || [[ -z "$TOKEN" ]]; then
|
||||
echo "❌ 錯誤:缺少必要的 inputs (gitea-server, repository, token)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
/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
|
||||
Reference in New Issue
Block a user