-
Notifications
You must be signed in to change notification settings - Fork 6
123 lines (107 loc) · 4.36 KB
/
Copy pathbuild-node-image.yaml
File metadata and controls
123 lines (107 loc) · 4.36 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
122
123
name: Build and Push Node Image
on:
push:
branches: [main]
paths:
- 'node-images/fedora/**'
pull_request:
paths:
- 'node-images/fedora/**'
workflow_dispatch:
inputs:
push:
description: 'Push image to registry'
required: false
default: 'false'
type: boolean
env:
PUSH_REGISTRY: ghcr.io/bootc-dev/bink
PUSH_IMAGE: node
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
container:
image: quay.io/fedora/fedora:43
options: --privileged --device /dev/kvm -v /var/lib/containers
steps:
- name: Install dependencies
run: dnf install -y --setopt=install_weak_deps=0 podman git make
- name: Checkout
uses: actions/checkout@v4
- name: Log in to GHCR
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
run: podman login -u ${{ github.actor }} -p ${{ secrets.GITHUB_TOKEN }} ghcr.io
- name: Build bootc image
working-directory: node-images/fedora
run: make build-bootc-image
- name: Determine image tag
id: meta
working-directory: node-images/fedora
run: |
TAG=$(make -s print-image-tag)
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "Image tag: ${TAG}"
- name: Push bootc image
id: push-bootc
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
working-directory: node-images/fedora
run: |
TAG=${{ steps.meta.outputs.tag }}
BOOTC_SRC=$(make -s print-bootc-image)
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
podman tag ${BOOTC_SRC} ${PUSH_DEST}:${TAG}
podman push --digestfile=/tmp/bootc-digest ${PUSH_DEST}:${TAG}
podman tag ${BOOTC_SRC} ${PUSH_DEST}:latest
podman push ${PUSH_DEST}:latest
BOOTC_DIGEST=$(cat /tmp/bootc-digest)
echo "digest=${BOOTC_DIGEST}" >> "$GITHUB_OUTPUT"
echo "Bootc image pushed with digest: ${BOOTC_DIGEST}"
echo "Clean up local images"
podman rmi -f ${BOOTC_SRC} ${PUSH_DEST}:${TAG} ${PUSH_DEST}:latest
echo "push_dest=${PUSH_DEST}:${TAG}" >> "$GITHUB_OUTPUT"
- name: Build disk image
working-directory: node-images/fedora
run: |
BOOTC_DIGEST="${{ steps.push-bootc.outputs.digest }}"
PUSH_DEST="${{ steps.push-bootc.outputs.push_dest }}"
if [ -n "${BOOTC_DIGEST}" ] && [ -n "${PUSH_DEST}" ]; then
podman pull "${PUSH_DEST}"
make build-disk-image BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
else
make build-disk-image
fi
- name: Push disk image
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
working-directory: node-images/fedora
run: |
TAG=${{ steps.meta.outputs.tag }}
DISK_SRC=$(make -s print-node-image)
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
podman tag ${DISK_SRC} ${PUSH_DEST}:${TAG}-disk
podman push ${PUSH_DEST}:${TAG}-disk
podman tag ${DISK_SRC} ${PUSH_DEST}:latest-disk
podman push ${PUSH_DEST}:latest-disk
- name: Build composefs disk image
working-directory: node-images/fedora
run: |
BOOTC_DIGEST="${{ steps.push-bootc.outputs.digest }}"
PUSH_DEST="${{ steps.push-bootc.outputs.push_dest }}"
if [ -n "${BOOTC_DIGEST}" ] && [ -n "${PUSH_DEST}" ]; then
make build-disk-image-composefs BOOTC_IMAGE="${PUSH_DEST}" BOOTC_DIGEST="${BOOTC_DIGEST}"
else
make build-disk-image-composefs
fi
- name: Push composefs disk image
if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.push)
working-directory: node-images/fedora
run: |
TAG=${{ steps.meta.outputs.tag }}
DISK_SRC=$(make -s print-node-image-composefs)
PUSH_DEST=${{ env.PUSH_REGISTRY }}/${{ env.PUSH_IMAGE }}
podman tag ${DISK_SRC} ${PUSH_DEST}:${TAG}-disk-composefs
podman push ${PUSH_DEST}:${TAG}-disk-composefs
podman tag ${DISK_SRC} ${PUSH_DEST}:latest-disk-composefs
podman push ${PUSH_DEST}:latest-disk-composefs