Skip to content

Commit fe27bc3

Browse files
committed
ci: add weekly CI container build and cleanup workflows
Add a Containerfile with all packages needed for testing and coverage, a workflow to build and push it weekly to ghcr.io for x86_64 and aarch64, and a cleanup workflow to prune old untagged container images. Generated with Claude Code (https://claude.ai/code) Signed-off-by: Adrian Reber <areber@redhat.com>
1 parent a9e0ef7 commit fe27bc3

3 files changed

Lines changed: 151 additions & 0 deletions

File tree

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Build and Publish CI Container
2+
3+
on:
4+
schedule:
5+
# Run every Monday at 06:00 UTC
6+
- cron: '0 6 * * 1'
7+
workflow_dispatch:
8+
9+
env:
10+
REGISTRY: ghcr.io
11+
12+
jobs:
13+
build:
14+
runs-on: ${{ matrix.runs-on }}
15+
permissions:
16+
contents: read
17+
packages: write
18+
strategy:
19+
matrix:
20+
arch: [ x86_64, aarch64 ]
21+
include:
22+
- arch: x86_64
23+
runs-on: ubuntu-24.04
24+
- arch: aarch64
25+
runs-on: ubuntu-24.04-arm
26+
outputs:
27+
digest-x86_64: ${{ steps.export.outputs.digest-x86_64 }}
28+
digest-aarch64: ${{ steps.export.outputs.digest-aarch64 }}
29+
steps:
30+
- name: Checkout repository
31+
uses: actions/checkout@v4
32+
33+
- name: Set up Docker Buildx
34+
uses: docker/setup-buildx-action@v3
35+
36+
- name: Log in to Container Registry
37+
uses: docker/login-action@v3
38+
with:
39+
registry: ${{ env.REGISTRY }}
40+
username: ${{ github.actor }}
41+
password: ${{ secrets.GITHUB_TOKEN }}
42+
43+
- name: Extract metadata
44+
id: meta
45+
uses: docker/metadata-action@v5
46+
with:
47+
images: ${{ env.REGISTRY }}/${{ github.repository }}/ci
48+
tags: |
49+
type=raw,value=latest
50+
51+
- name: Build and push by digest
52+
id: build
53+
uses: docker/build-push-action@v6
54+
with:
55+
context: .
56+
file: ./test/ci/Containerfile
57+
platforms: linux/${{ matrix.arch }}
58+
labels: ${{ steps.meta.outputs.labels }}
59+
provenance: false
60+
sbom: false
61+
outputs: type=image,name=${{ env.REGISTRY }}/${{ github.repository }}/ci,push-by-digest=true,name-canonical=true,push=true
62+
63+
- name: Export digest
64+
id: export
65+
run: |
66+
echo "digest-${{ matrix.arch }}=${{ steps.build.outputs.digest }}" >> $GITHUB_OUTPUT
67+
68+
publish:
69+
runs-on: ubuntu-24.04
70+
needs: build
71+
permissions:
72+
contents: read
73+
packages: write
74+
steps:
75+
- name: Set up Docker Buildx
76+
uses: docker/setup-buildx-action@v3
77+
78+
- name: Log in to Container Registry
79+
uses: docker/login-action@v3
80+
with:
81+
registry: ${{ env.REGISTRY }}
82+
username: ${{ github.actor }}
83+
password: ${{ secrets.GITHUB_TOKEN }}
84+
85+
- name: Create and push manifest
86+
run: |
87+
docker buildx imagetools create \
88+
--tag ${{ env.REGISTRY }}/${{ github.repository }}/ci:latest \
89+
${{ env.REGISTRY }}/${{ github.repository }}/ci@${{ needs.build.outputs.digest-x86_64 }} \
90+
${{ env.REGISTRY }}/${{ github.repository }}/ci@${{ needs.build.outputs.digest-aarch64 }}
91+
92+
- name: Output image details
93+
run: |
94+
echo "Container built and pushed successfully!"
95+
echo "Image: ${{ env.REGISTRY }}/${{ github.repository }}/ci:latest"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Cleanup Untagged Packages
2+
3+
on:
4+
schedule:
5+
# Run every Sunday at 02:00 UTC
6+
- cron: '0 2 * * 0'
7+
workflow_dispatch:
8+
9+
jobs:
10+
cleanup:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- name: Delete untagged CI container images
17+
id: cleanup-ci
18+
continue-on-error: true
19+
uses: actions/delete-package-versions@v5
20+
with:
21+
package-name: checkpointctl/ci
22+
package-type: container
23+
min-versions-to-keep: 3
24+
delete-only-untagged-versions: true
25+
token: ${{ secrets.GITHUB_TOKEN }}
26+
27+
- name: Report cleanup results
28+
run: |
29+
echo "Cleanup Results:"
30+
echo "CI container cleanup: ${{ steps.cleanup-ci.outcome }}"
31+
32+
if [[ "${{ steps.cleanup-ci.outcome }}" == "failure" ]]; then
33+
echo "Warning: CI container cleanup failed"
34+
echo "Package may not exist yet"
35+
fi
36+
37+
echo "Cleanup workflow completed"

test/ci/Containerfile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM registry.fedoraproject.org/fedora:latest
2+
3+
RUN dnf install -y \
4+
bash \
5+
bash-completion \
6+
bats \
7+
criu \
8+
fish \
9+
git \
10+
golang \
11+
iptables \
12+
iproute \
13+
jq \
14+
kmod \
15+
make \
16+
rubygem-asciidoctor \
17+
ShellCheck \
18+
zsh \
19+
&& dnf clean all

0 commit comments

Comments
 (0)