-
Notifications
You must be signed in to change notification settings - Fork 7
121 lines (100 loc) · 3.66 KB
/
Copy pathbuild-container.yml
File metadata and controls
121 lines (100 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# Build and publish the devaipod container image to ghcr.io
name: Build Container
on:
push:
branches: [main]
tags: ['v*']
permissions:
contents: read
packages: write
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-test:
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v4
- name: Setup host (newer podman with heredoc support, just)
uses: bootc-dev/actions/bootc-ubuntu-setup@main
- name: Build and test container
run: just container-test
# Multi-arch build and push (only on push to main or tags)
push:
if: github.event_name != 'pull_request'
needs: build-and-test
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
arch: [amd64, arm64]
include:
- arch: amd64
runner: ubuntu-24.04
- arch: arm64
runner: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- name: Setup host (newer podman with heredoc support, just)
uses: bootc-dev/actions/bootc-ubuntu-setup@main
- name: Log in to Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login -u ${{ github.actor }} --password-stdin ${{ env.REGISTRY }}
- name: Build container
run: just container-build
# Retag the locally-built image for the registry.
# The Justfile builds as localhost/devaipod for local dev; CI needs the
# registry name so that podman push targets the right destination.
- name: Tag for registry
run: podman tag localhost/devaipod:latest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Push by digest
id: push
run: |
digest=$(podman push --digestfile /tmp/digest ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest && cat /tmp/digest)
echo "digest=${digest}" >> "$GITHUB_OUTPUT"
mkdir -p /tmp/digests
touch "/tmp/digests/${digest#sha256:}"
- name: Upload digest
uses: actions/upload-artifact@v4
with:
name: digests-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
# Create multi-arch manifest
manifest:
runs-on: ubuntu-24.04
needs: push
if: github.event_name != 'pull_request'
steps:
- name: Download digests
uses: actions/download-artifact@v4
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix={{branch}}-,format=short,enable=${{ github.ref_type != 'tag' }}
type=ref,event=tag
- name: Log in to Container Registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | podman login -u ${{ github.actor }} --password-stdin ${{ env.REGISTRY }}
- name: Create and push manifest
run: |
tags=$(echo '${{ steps.meta.outputs.tags }}' | tr '\n' ' ')
digests=$(cd /tmp/digests && printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
for tag in $tags; do
podman manifest create "$tag" $digests
podman manifest push "$tag" "$tag"
done
- name: Inspect image
run: podman manifest inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}