Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .github/workflows/purge-cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,7 @@ jobs:
docker buildx imagetools create -t "${CACHE_REPO}:keep" docker.io/library/hello-world:latest
OWNER_TYPE=$(gh api "users/${{ github.repository_owner }}" --jq 'if .type == "Organization" then "orgs" else "users" end')
VERSIONS="${OWNER_TYPE}/${{ github.repository_owner }}/packages/container/php-cache/versions"
gh api --paginate "${VERSIONS}" --jq '.[] | select(.metadata.container.tags | index("keep") | not) | .id' \
| xargs -r -I {} gh api --silent -X DELETE "${VERSIONS}/{}"
# The whole list is read before the deletions, which shift the next pages
IDS=$(gh api --paginate "${VERSIONS}" --jq '.[] | select(.metadata.container.tags | index("keep") | not) | .id')
printf '%s\n' ${IDS} | xargs -r -I {} gh api --silent -X DELETE "${VERSIONS}/{}"
echo "$(printf '%s\n' ${IDS} | grep -c .) versions deleted"
26 changes: 24 additions & 2 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,30 @@ jobs:
TAG_PREFIX="rc${GITHUB_RUN_ID}-" \
docker buildx bake \
--set "*.platform=linux/${{ matrix.builder.arch }}" \
--progress=quiet \
php${PHP_VERSION//.}
--progress=plain \
php${PHP_VERSION//.} > build.log 2>&1 || { tail -n 50 build.log; exit 1; }
- name: Upload the build log
if: always()
uses: actions/upload-artifact@v7
with:
name: build-log-${{ matrix.php_version }}-${{ matrix.builder.arch }}
path: build.log
retention-days: 7
- name: Check the cache tags
if: ${{ github.event_name != 'pull_request' }}
run: |
PHP_VERSION="${{ matrix.php_version }}"
CACHE_REPO="${{ github.repository_owner }}/php-cache"
EXPECTED=$(CACHE_REPO="ghcr.io/${CACHE_REPO}" CACHE_WRITE=1 ARCH_SUFFIX="-${{ matrix.builder.arch }}" \
docker buildx bake --print --progress=quiet php${PHP_VERSION//.} \
| jq -r '.target[]."cache-to"[]?.ref | sub(".*:"; "")' | sort)
# Anonymous token: the cache package is public
TOKEN=$(curl -fsS "https://ghcr.io/token?scope=repository:${CACHE_REPO}:pull" | jq -r .token)
EXISTING=$(curl -fsS -H "Authorization: Bearer ${TOKEN}" "https://ghcr.io/v2/${CACHE_REPO}/tags/list?n=1000" | jq -r '.tags[]' | sort)
MISSING=$(comm -23 <(echo "${EXPECTED}") <(echo "${EXISTING}"))
if [ -n "${MISSING}" ]; then
echo "::warning::Cache tags not written (see the export lines of build.log): $(echo ${MISSING})"
fi
- name: Display tags built
run: |
docker image ls --filter="reference=ghcr.io/${{ github.repository_owner }}/php" --format "{{.CreatedAt}}\t{{.Size}}\t{{.Repository}}:{{.Tag}}"
Expand Down