1
0

add cleanup
Some checks are pending
FoundryVTT Container Build / Build FoundryVTT Container (push) Waiting to run
FoundryVTT Container Build / cleanup (push) Waiting to run

This commit is contained in:
tbelway 2026-02-14 15:04:42 -05:00
parent 97708959c7
commit eaae361018
2 changed files with 48 additions and 12 deletions

View File

@ -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 were 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

View File

@ -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"]