diff --git a/.gitea/workflows/build-container.yml b/.gitea/workflows/build-container.yml index 816e935..0c7386e 100644 --- a/.gitea/workflows/build-container.yml +++ b/.gitea/workflows/build-container.yml @@ -76,7 +76,7 @@ jobs: chmod +x scripts/get_foundry_version.sh FOUNDRY_VERSION=$(bash scripts/get_foundry_version.sh --version-only) fi - + echo "FOUNDRY_VERSION=${FOUNDRY_VERSION}" >> $GITHUB_ENV echo "FoundryVTT version: ${FOUNDRY_VERSION}" @@ -97,12 +97,12 @@ jobs: echo "Authenticating to FoundryVTT..." chmod +x scripts/get_foundry_download.sh FOUNDRY_URL=$(bash scripts/get_foundry_download.sh --url-only --version "${FOUNDRY_VERSION}") - + if [[ -z "${FOUNDRY_URL}" || "${FOUNDRY_URL}" == "null" ]]; then echo "Error: Failed to get download URL from FoundryVTT" exit 1 fi - + # Mask the URL in logs (contains timed token) echo "::add-mask::${FOUNDRY_URL}" echo "FOUNDRY_URL=${FOUNDRY_URL}" >> $GITHUB_ENV @@ -112,10 +112,10 @@ jobs: working-directory: ./foundryvtt_container run: | set -e - + SHOULD_BUILD=false FORCE_BUILD="${{ inputs.force_build }}" - + if [[ "${FORCE_BUILD}" == "true" ]]; then SHOULD_BUILD=true elif [[ "${EXISTING_VERSION}" == "none" ]]; then @@ -125,12 +125,12 @@ jobs: elif [[ "${{ gitea.event_name }}" == "push" ]]; then SHOULD_BUILD=true fi - + if [[ "${SHOULD_BUILD}" == "true" ]]; then echo "Building FoundryVTT image..." - + IMAGE_NAME="${IMAGE_REGISTRY}/${IMAGE_NAMESPACE}:${FOUNDRY_VERSION}" - + podman build \ --platform linux/amd64 \ --format oci \ @@ -143,13 +143,13 @@ jobs: -f Containerfile \ -t "${IMAGE_NAME}" \ . - + podman push "${IMAGE_NAME}" - + # Also tag as latest podman tag "${IMAGE_NAME}" "${IMAGE_REGISTRY}/${IMAGE_NAMESPACE}:latest" podman push "${IMAGE_REGISTRY}/${IMAGE_NAMESPACE}:latest" - + echo "BUILD_STATUS=success" >> $GITHUB_ENV echo "βœ… Successfully built FoundryVTT ${FOUNDRY_VERSION}" else @@ -172,3 +172,39 @@ jobs: echo " Registry: ${IMAGE_REGISTRY}/${IMAGE_NAMESPACE}" echo " Tags: ${FOUNDRY_VERSION}, latest" echo "" + + cleanup: + runs-on: podman-stable + # Make sure the build waits for us + needs: [] # (explicitly no dependencies) + steps: + # 1️⃣ OPTIONAL: list what we’re about to toss + - name: πŸ“¦ List existing artifacts (debug) + id: list_artifacts + uses: actions/artifact@v3 + with: + action: list + # Adjust the pattern to whatever you actually name your artifacts + name: "foundryvtt-build-*" + + # 2️⃣ THE REAL CLEANUP + - name: πŸ—‘οΈ Delete stale artifacts + uses: actions/artifact@v3 + with: + action: delete + # Same pattern as above – deletes everything that matches + name: "foundryvtt-build-*" + # Keep the newest N artifacts (set to 0 to purge all) + keep_latest: 2 # ← keep the two most recent builds, optional + + # 3️⃣ Log what happened (nice for audit trails) + - name: πŸ“Š Report deletion outcome + if: always() + run: | + echo "Deleted artifacts matching 'foundryvtt-build-*'." + if [[ -n \"${{ steps.list_artifacts.outputs.artifacts }}\" ]]; then + echo "Previously present artifacts:" + echo "${{ steps.list_artifacts.outputs.artifacts }}" + else + echo "No artifacts were found." + fi diff --git a/Containerfile b/Containerfile index c078a3d..462da70 100644 --- a/Containerfile +++ b/Containerfile @@ -52,4 +52,4 @@ EXPOSE 30000 LABEL org.opencontainers.image.version="${FOUNDRY_VERSION}" # Use exec form for proper signal handling -ENTRYPOINT ["/usr/bin/node", "/foundryvtt/app/resources/app/main.js", "--dataPath=/foundryvtt/data"] +ENTRYPOINT ["/usr/bin/node", "/foundryvtt/app/main.js", "--dataPath=/foundryvtt/data"]