Test action main branch #2264
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Test action main branch | |
on: | |
workflow_dispatch: | |
schedule: | |
- cron: "5 * * * *" # every hour | |
jobs: | |
clean: | |
runs-on: ubuntu-latest | |
name: Ubuntu with classic personal access token | |
steps: | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3.0.0 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Fetch multi-platform package version SHAs | |
id: multi-arch-digests | |
run: | | |
digest=$(docker manifest inspect ghcr.io/snok/container-retention-policy:v3.0.0 | jq -r '.manifests[].digest' | paste -s -d ' ' -) | |
echo "multi-arch-digests=$digest" >> $GITHUB_OUTPUT | |
- uses: snok/container-retention-policy@main | |
name: Delete test-1-* images with a temporal token | |
with: | |
account: snok | |
token: ${{ secrets.GITHUB_TOKEN }} | |
cut-off: 2h | |
image-names: container-retention-policy | |
image-tags: test-* !test-2* !test-3* !test-4* !test-5* | |
tag-selection: both | |
timestamp-to-use: created_at | |
dry-run: false | |
rust-log: container_retention_policy=debug | |
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} | |
- name: Generate a token | |
id: generate-token | |
uses: actions/create-github-app-token@v1 | |
with: | |
app-id: 911530 | |
private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
- uses: snok/container-retention-policy@main | |
name: Delete test-2-* images with an Github app token | |
with: | |
account: snok | |
token: ${{ steps.generate-token.outputs.token }} | |
cut-off: 2h | |
image-names: container-retention-policy | |
image-tags: test-* !test-3* !test-4* !test-5* | |
tag-selection: both | |
timestamp-to-use: created_at | |
dry-run: false | |
rust-log: container_retention_policy=debug | |
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} | |
- uses: snok/container-retention-policy@main | |
name: Delete remaining test images with a PAT | |
with: | |
account: snok | |
token: ${{ secrets.PAT }} | |
cut-off: 2h | |
image-names: container-retention-policy | |
image-tags: test-* | |
tag-selection: both | |
timestamp-to-use: created_at | |
dry-run: false | |
rust-log: container_retention_policy=debug | |
skip-shas: ${{ steps.multi-arch-digests.outputs.multi-arch-digests }} | |
produce: | |
runs-on: ubuntu-latest | |
name: Upload more test images | |
steps: | |
- uses: docker/setup-buildx-action@v3 | |
- uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build empty images | |
run: | | |
for ((i=1; i<=5; i++)) | |
do | |
randomString=$(LC_ALL=C tr -dc A-Za-z0-9 </dev/urandom | head -c 10 2>/dev/null || echo RANDOM) | |
{ | |
echo "FROM alpine as builder" | |
echo "RUN echo \"$randomString\" > test.txt" | |
echo "FROM scratch" | |
echo "COPY --from=builder /test.txt ." | |
} > Dockerfile | |
imageName="ghcr.io/snok/container-retention-policy:test-${i}" | |
docker build -f Dockerfile -t "$imageName" --push . | |
for ((j=1; j<=3; j++)) | |
do | |
docker tag "$imageName" "ghcr.io/snok/container-retention-policy:test-${i}-${j}" | |
docker push "ghcr.io/snok/container-retention-policy:test-${i}-${j}" | |
done | |
done |