Skip to content

Commit 013b48c

Browse files
committed
.github/workflows: add workflow to build container
1 parent b209997 commit 013b48c

File tree

1 file changed

+98
-0
lines changed

1 file changed

+98
-0
lines changed

.github/workflows/container.yaml

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
---
2+
name: 'Build container'
3+
4+
on:
5+
workflow_dispatch:
6+
pull_request:
7+
branches:
8+
- master
9+
paths:
10+
- container/**
11+
push:
12+
branches:
13+
- master
14+
paths:
15+
- container/**
16+
17+
concurrency:
18+
group: ${{ github.workflow }}-${{ github.ref }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
25+
permissions:
26+
contents: read
27+
packages: write
28+
29+
strategy:
30+
matrix:
31+
libc:
32+
- glibc
33+
- musl
34+
35+
steps:
36+
- name: Checkout
37+
uses: classabbyamp/treeless-checkout-action@v1
38+
39+
- name: Get image release
40+
id: release
41+
run: |
42+
# gets the list of all date-shaped tags for the image, finds the most recent one
43+
tag="$(skopeo list-tags "docker://ghcr.io/${{ github.repository_owner }}/void-buildroot-${{ matrix.libc }}" | \
44+
jq -r '.Tags | sort | reverse | map(select(test("^[0-9]{8}(R[0-9]+)?$")))[0]')"
45+
# tags from a different day or pre-YYYYMMDDRN
46+
if [ "${tag%R*}" != "$(date -u +%Y%m%d)" ] || [ "${tag%R*}" = "${tag}" ]; then
47+
rel=1
48+
else
49+
rel=$(( ${tag##*R} + 1 ))
50+
fi
51+
echo "rel=${rel}" >> "${GITHUB_OUTPUT}"
52+
53+
- name: Docker metadata
54+
id: meta
55+
uses: docker/metadata-action@v4
56+
with:
57+
images: |
58+
ghcr.io/${{ github.repository_owner }}/void-buildroot-${{ matrix.libc }}
59+
tags: |
60+
type=sha,prefix=
61+
type=raw,value=latest,enable={{is_default_branch}}
62+
type=raw,value={{date 'YYYYMMDD'}}R${{ steps.release.outputs.rel }},enable={{is_default_branch}},priority=1000
63+
flavor: latest=false
64+
labels: |
65+
org.opencontainers.image.authors=Void Linux team and contributors
66+
org.opencontainers.image.url=https://voidlinux.org
67+
org.opencontainers.image.documentation=https://github.com/${{ github.repository }}
68+
org.opencontainers.image.source=https://github.com/${{ github.repository }}
69+
org.opencontainers.image.vendor=Void Linux
70+
org.opencontainers.image.title=Void Linux mklive container
71+
org.opencontainers.image.description=Image for building mklive images
72+
73+
- name: Set up QEMU
74+
uses: docker/setup-qemu-action@v2
75+
76+
- name: Set up Docker Buildx
77+
uses: docker/setup-buildx-action@v2
78+
79+
- name: Login to GCHR
80+
if: github.event_name != 'pull_request'
81+
uses: docker/login-action@v2
82+
with:
83+
registry: ghcr.io
84+
username: ${{ github.actor }}
85+
password: ${{ secrets.GITHUB_TOKEN }}
86+
87+
- name: Build and push images
88+
id: build_and_push
89+
uses: docker/bake-action@v3
90+
with:
91+
push: ${{ github.event_name != 'pull_request' }}
92+
targets: void-mklive
93+
files: |
94+
container/docker-bake.hcl
95+
${{ steps.meta.outputs.bake-file }}
96+
set: |
97+
_common.cache-to=type=gha
98+
_common.cache-from=type=gha

0 commit comments

Comments
 (0)