Skip to content

Commit f3e65f3

Browse files
Jonathan D.A. Jewellclaude
andcommitted
Switch GHCR workflow to nerdctl
Replace docker/buildx with nerdctl for container builds 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent cae5f45 commit f3e65f3

1 file changed

Lines changed: 31 additions & 34 deletions

File tree

.github/workflows/ghcr-publish.yml

Lines changed: 31 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,42 +32,39 @@ jobs:
3232
- name: Checkout repository
3333
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4
3434

35-
- name: Set up Docker Buildx
36-
uses: docker/setup-buildx-action@c47758b77c9736f4b2ef4073d4d51994fabfe349 # v3
35+
- name: Install nerdctl and containerd
36+
run: |
37+
# Install containerd
38+
sudo apt-get update
39+
sudo apt-get install -y containerd
40+
sudo systemctl start containerd
41+
42+
# Install nerdctl
43+
NERDCTL_VERSION=2.0.2
44+
curl -sSL "https://github.com/containerd/nerdctl/releases/download/v${NERDCTL_VERSION}/nerdctl-${NERDCTL_VERSION}-linux-amd64.tar.gz" | sudo tar -xz -C /usr/local/bin
45+
46+
# Install CNI plugins
47+
CNI_VERSION=1.6.1
48+
sudo mkdir -p /opt/cni/bin
49+
curl -sSL "https://github.com/containernetworking/plugins/releases/download/v${CNI_VERSION}/cni-plugins-linux-amd64-v${CNI_VERSION}.tgz" | sudo tar -xz -C /opt/cni/bin
3750
3851
- name: Log in to GHCR
39-
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
40-
with:
41-
registry: ${{ env.REGISTRY }}
42-
username: ${{ github.actor }}
43-
password: ${{ secrets.GITHUB_TOKEN }}
52+
run: |
53+
echo "${{ secrets.GITHUB_TOKEN }}" | sudo nerdctl login ghcr.io -u ${{ github.actor }} --password-stdin
4454
45-
- name: Extract metadata
46-
id: meta
47-
uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # v5
48-
with:
49-
images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}
50-
tags: |
51-
type=semver,pattern={{version}}
52-
type=semver,pattern={{major}}.{{minor}}
53-
type=ref,event=branch
54-
type=sha
55+
- name: Build image
56+
run: |
57+
sudo nerdctl build --target ${{ matrix.target.dockerfile-target }} -t ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${{ github.sha }} .
58+
sudo nerdctl tag ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:latest
5559
56-
- name: Build and push
57-
id: push
58-
uses: docker/build-push-action@4f58ea79222b3b9dc2c8bbdd6debcef730109a75 # v6
59-
with:
60-
context: .
61-
target: ${{ matrix.target.dockerfile-target }}
62-
push: true
63-
tags: ${{ steps.meta.outputs.tags }}
64-
labels: ${{ steps.meta.outputs.labels }}
65-
cache-from: type=gha
66-
cache-to: type=gha,mode=max
60+
- name: Push image
61+
run: |
62+
sudo nerdctl push ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${{ github.sha }}
63+
sudo nerdctl push ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:latest
6764
68-
- name: Generate artifact attestation
69-
uses: actions/attest-build-provenance@ef244123eb79f2f7a7e75d99086184180e6d0018 # v2
70-
with:
71-
subject-name: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}
72-
subject-digest: ${{ steps.push.outputs.digest }}
73-
push-to-registry: true
65+
- name: Tag release version
66+
if: github.event_name == 'release'
67+
run: |
68+
VERSION=${{ github.event.release.tag_name }}
69+
sudo nerdctl tag ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${{ github.sha }} ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${VERSION}
70+
sudo nerdctl push ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.target.name }}:${VERSION}

0 commit comments

Comments
 (0)