Skip to content

Commit 49065e2

Browse files
committed
feat(buildah-action-runner): create a buildah image to use in runners
1 parent dcb02be commit 49065e2

7 files changed

Lines changed: 141 additions & 0 deletions

File tree

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
---
2+
name: Build Buildah Action Runner Image
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches:
7+
- main
8+
paths:
9+
- .github/workflows/image-buildah-action-runner.yml
10+
- images/buildah-action-runner/**
11+
tags:
12+
- buildah-action-runner-*
13+
pull_request:
14+
branches:
15+
- main
16+
paths:
17+
- .github/workflows/image-buildah-action-runner.yml
18+
- images/buildah-action-runner/**
19+
20+
jobs:
21+
build-buildah-action-runner:
22+
name: Build Buildah Action Runner Image
23+
runs-on: ubuntu-latest
24+
permissions:
25+
contents: read
26+
packages: write
27+
28+
steps:
29+
- name: Checkout Repo
30+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
31+
- name: Login to GitHub Container Registry
32+
uses: docker/login-action@af1e73f918a031802d376d3c8bbc3fe56130a9b0 # v4
33+
with:
34+
registry: ghcr.io
35+
username: ${{ github.actor }}
36+
password: ${{ secrets.GITHUB_TOKEN }}
37+
- name: Compute Version Tag
38+
env:
39+
BRANCH: ${{ github.ref_type == 'tag' && github.ref_name || github.event_name != 'pull_request' && format('{0}.{1}.{2}', github.run_id, github.run_number, github.run_attempt) || format('pr-{0}.{1}.{2}.{3}', github.event.number, github.run_id, github.run_number, github.run_attempt) }}
40+
id: version_tag
41+
run: echo "tag=$BRANCH" | sed -e 's/buildah-action-runner-//' >> "$GITHUB_OUTPUT"
42+
- name: Select Image Export Mode
43+
id: image_export
44+
env:
45+
HEAD_REPOSITORY: ${{ github.event.pull_request.head.repo.full_name }}
46+
run: |
47+
set -euo pipefail
48+
49+
if [[ "${GITHUB_EVENT_NAME}" == "pull_request" && "${HEAD_REPOSITORY}" != "${GITHUB_REPOSITORY}" ]]; then
50+
echo "load=true" >> "$GITHUB_OUTPUT"
51+
echo "push=false" >> "$GITHUB_OUTPUT"
52+
else
53+
echo "load=false" >> "$GITHUB_OUTPUT"
54+
echo "push=true" >> "$GITHUB_OUTPUT"
55+
fi
56+
- name: Generate Metadata
57+
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
58+
id: metadata
59+
with:
60+
images: ghcr.io/${{ github.repository_owner }}/buildah-action-runner
61+
- name: Build Image
62+
id: build
63+
uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0
64+
with:
65+
context: images/buildah-action-runner
66+
file: images/buildah-action-runner/Containerfile
67+
labels: ${{ steps.metadata.outputs.labels }}
68+
load: ${{ steps.image_export.outputs.load }}
69+
push: ${{ steps.image_export.outputs.push }}
70+
tags: ghcr.io/${{ github.repository_owner }}/buildah-action-runner:${{ steps.version_tag.outputs.tag }}
71+
- name: Smoke Test Image
72+
run: |
73+
docker run --rm ghcr.io/${{ github.repository_owner }}/buildah-action-runner:${{ steps.version_tag.outputs.tag }} bash -lc '
74+
buildah --version
75+
curl --version
76+
jq --version
77+
node --version
78+
'
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM scratch AS ctx
2+
COPY build_files /
3+
4+
FROM quay.io/buildah/stable:v1.43.1@sha256:ca4edbaabf71ca330ec9b2714bf8e06c726a6e85ae215cfb1474d2e2c832aacb
5+
6+
LABEL org.opencontainers.image.title="buildah-action-runner"
7+
LABEL org.opencontainers.image.description="Tools needed for a minimal buildah environment in CI."
8+
9+
RUN --mount=type=bind,from=ctx,source=/,target=/ctx \
10+
--mount=type=cache,dst=/var/cache \
11+
--mount=type=cache,dst=/var/lib/dnf \
12+
--mount=type=cache,dst=/var/log \
13+
--mount=type=tmpfs,dst=/tmp \
14+
/ctx/build.sh
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Marinated Concrete's Buildah Action Runner Image
2+
3+
This image extends the upstream `quay.io/buildah/stable` image with the tools needed
4+
for a minimal buildah environment in CI: `jq`, `curl`, and Node.js, for jobs that build
5+
containers with `buildah` and also need common scripting tools.
6+
7+
We publish semantically-versioned releases via release-please.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env bash
2+
3+
set -ouex pipefail
4+
5+
/ctx/packages.sh
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/usr/bin/env bash
2+
3+
set -eoux pipefail
4+
5+
PACKAGES=(
6+
"curl"
7+
"jq"
8+
"nodejs"
9+
)
10+
11+
# Unlike other, wider images we have, we do not run `dnf upgrade -y` here.
12+
# The base image is pinned by digest, and upgrading here could potentially
13+
# pull newer buildah/fuse-overlayfs/etc. out from under that pin, defeating
14+
# the entire purpose of the pin!
15+
dnf install \
16+
--setopt=install_weak_deps=False \
17+
-y \
18+
"${PACKAGES[@]}"

release-please-config.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@
4343
"package-name": "ansible-collection",
4444
"release-type": "simple"
4545
},
46+
"images/buildah-action-runner": {
47+
"include-v-in-tag": false,
48+
"package-name": "buildah-action-runner",
49+
"release-type": "simple",
50+
"tag-separator": "-"
51+
},
4652
"images/kairos-fedora": {
4753
"include-v-in-tag": false,
4854
"package-name": "kairos-fedora",

renovate/marinatedconcrete.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
"matchPackageNames": ["marinatedconcrete/config"],
3535
"versioning": "regex:^(?<compatibility>.+)[@\\-]v?(?<major>\\d+?)\\.(?<minor>\\d+?)\\.(?<patch>\\d+?)$"
3636
},
37+
{
38+
"description": "Map buildah-action-runner image to its monorepo changelog",
39+
"matchDatasources": ["docker"],
40+
"matchPackageNames": ["ghcr.io/marinatedconcrete/buildah-action-runner"],
41+
"sourceDirectory": "images/buildah-action-runner",
42+
"sourceUrl": "https://github.com/marinatedconcrete/config"
43+
},
3744
{
3845
"description": "Map kairos-fedora image to its monorepo changelog",
3946
"matchDatasources": ["docker"],
@@ -53,6 +60,12 @@
5360
"matchCurrentValue": "ansible-collection@**",
5461
"matchPackageNames": ["marinatedconcrete/config"]
5562
},
63+
{
64+
"groupName": "marinatedconcrete Buildah Action Runner Image",
65+
"groupSlug": "marinatedconcrete-buildah-action-runner",
66+
"matchCurrentValue": "buildah-action-runner-**",
67+
"matchPackageNames": ["marinatedconcrete/config"]
68+
},
5669
{
5770
"groupName": "marinatedconcrete Kairos Fedora Image",
5871
"groupSlug": "marinatedconcrete-kairos-fedora",

0 commit comments

Comments
 (0)