Skip to content

Commit 094c39d

Browse files
committed
ci: Split image publishing into separate workflow for security
Previously, the CI workflow granted packages:write permission at the workflow level, making GITHUB_TOKEN with write access available to all jobs including those running on pull requests. While the actual push steps were gated with conditionals, malicious PR code could use the token to push arbitrary images to ghcr.io. Split image publishing into a dedicated build-and-publish.yml workflow that only runs on push to main, with no PR execution. This follows GitHub security best practices by isolating write credentials from untrusted PR code. The new workflow builds and publishes all image variants using a simple matrix with explicit exclude for centos-9 UKI (broken per #1812). Assisted-by: Claude Code (Sonnet 4.5) Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 136593a commit 094c39d

2 files changed

Lines changed: 62 additions & 29 deletions

File tree

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Build and Publish Images
2+
3+
permissions:
4+
packages: write
5+
6+
on:
7+
push:
8+
branches: [main]
9+
workflow_dispatch: {}
10+
11+
env:
12+
CARGO_TERM_COLOR: always
13+
LIBVIRT_DEFAULT_URI: "qemu:///session"
14+
DEV_IMAGE: ghcr.io/bootc-dev/dev-bootc
15+
16+
jobs:
17+
# Build and publish container images to ghcr.io
18+
publish-images:
19+
strategy:
20+
matrix:
21+
test_os: [fedora-42, fedora-43, fedora-44, centos-9, centos-10]
22+
variant: [ostree, composefs-sealeduki-sdboot]
23+
exclude:
24+
# centos-9 UKI is experimental/broken (https://github.com/bootc-dev/bootc/issues/1812)
25+
- test_os: centos-9
26+
variant: composefs-sealeduki-sdboot
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- uses: actions/checkout@v6
30+
- name: Bootc Ubuntu Setup
31+
uses: ./.github/actions/bootc-ubuntu-setup
32+
33+
- name: Setup env
34+
run: |
35+
BASE=$(just pullspec-for-os base ${{ matrix.test_os }})
36+
echo "BOOTC_base=${BASE}" >> $GITHUB_ENV
37+
echo "BOOTC_variant=${{ matrix.variant }}" >> $GITHUB_ENV
38+
39+
if [ "${{ matrix.variant }}" = "composefs-sealeduki-sdboot" ]; then
40+
BUILDROOTBASE=$(just pullspec-for-os buildroot-base ${{ matrix.test_os }})
41+
echo "BOOTC_buildroot_base=${BUILDROOTBASE}" >> $GITHUB_ENV
42+
fi
43+
44+
- name: Build container
45+
run: just build-integration-test-image
46+
47+
- name: Login to ghcr.io
48+
uses: redhat-actions/podman-login@v1
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.actor }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
54+
- name: Push container image
55+
run: |
56+
if [ "${{ matrix.variant }}" = "composefs-sealeduki-sdboot" ]; then
57+
TAG="${{ matrix.test_os }}-uki"
58+
else
59+
TAG="${{ matrix.test_os }}"
60+
fi
61+
podman tag localhost/bootc ${{ env.DEV_IMAGE }}:${TAG}
62+
podman push ${{ env.DEV_IMAGE }}:${TAG}

.github/workflows/ci.yml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ name: CI
1010

1111
permissions:
1212
actions: read
13-
packages: write
1413

1514
on:
1615
push:
@@ -159,20 +158,6 @@ jobs:
159158
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-ostree-${{ env.ARCH }}
160159
path: /var/tmp/tmt
161160

162-
- name: Login to ghcr.io
163-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
164-
uses: redhat-actions/podman-login@v1
165-
with:
166-
registry: ghcr.io
167-
username: ${{ github.actor }}
168-
password: ${{ secrets.GITHUB_TOKEN }}
169-
170-
- name: Push container image
171-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
172-
run: |
173-
podman tag localhost/bootc ${{ env.DEV_IMAGE }}:${{ matrix.test_os }}
174-
podman push ${{ env.DEV_IMAGE }}:${{ matrix.test_os }}
175-
176161
# This variant does composefs testing
177162
test-integration-cfs:
178163
continue-on-error: ${{ matrix.experimental }}
@@ -229,20 +214,6 @@ jobs:
229214
name: tmt-log-PR-${{ github.event.number }}-${{ matrix.test_os }}-cfs-${{ env.ARCH }}
230215
path: /var/tmp/tmt
231216

232-
- name: Login to ghcr.io
233-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
234-
uses: redhat-actions/podman-login@v1
235-
with:
236-
registry: ghcr.io
237-
username: ${{ github.actor }}
238-
password: ${{ secrets.GITHUB_TOKEN }}
239-
240-
- name: Push container image
241-
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
242-
run: |
243-
podman tag localhost/bootc ${{ env.DEV_IMAGE }}:stream10-uki
244-
podman push ${{ env.DEV_IMAGE }}:stream10-uki
245-
246217
# Sentinel job for required checks - configure this job name in repository settings
247218
required-checks:
248219
if: always()

0 commit comments

Comments
 (0)