Skip to content

Commit

Permalink
chore: Update test workflow to test v3-develop branch
Browse files Browse the repository at this point in the history
One final test run before merging v3.
  • Loading branch information
sondrelg committed Jun 24, 2024
1 parent e6eea47 commit 178bc0b
Showing 1 changed file with 62 additions and 14 deletions.
76 changes: 62 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,87 @@
name: Produce packages
name: Test action main branch

on:
workflow_dispatch:
schedule:
- cron: "*/3 * * * *" # every 3 hours
- cron: "5 * * * *" # every hour

jobs:
build:
clean:
runs-on: ubuntu-latest
name: Ubuntu with classic personal access token
steps:
- uses: snok/container-retention-policy@v3-develop
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: tagged
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug

- 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@v3-develop
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: tagged
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug

- uses: snok/container-retention-policy@v3-develop
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: tagged
timestamp-to-use: created_at
dry-run: false
rust-log: container_retention_policy=debug

produce:
runs-on: ubuntu-latest
name: Upload more test images
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build latest
- 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" > Dockerfile
echo "RUN echo \"$randomString\" > test.txt" >> Dockerfile
echo "FROM scratch" >> Dockerfile
echo "COPY --from=builder /test.txt ." >> Dockerfile
{
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
done

0 comments on commit 178bc0b

Please sign in to comment.