Repository navigation
95 lines (81 loc) · 2.65 KB
/
Copy pathbuild-push.yml
File metadata and controls
95 lines (81 loc) · 2.65 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
# lmndev-runner: Build and push Docker images to GHCR
#
# Triggered on push to main (excluding documentation and the workflow
# samples in workflows/, which are not part of the image) or manually
# via workflow_dispatch.
# Builds one image per Ubuntu version defined in the matrix;
# the primary version (currently 26.04) also receives the :latest tag.
#
# thomas@linuxmuster.net
# 20261003
name: Build and Push Docker Image
on:
schedule:
- cron: '0 3 * * 1'
push:
branches:
- main
paths-ignore:
- "*.md"
- "*.md.de"
- "workflows/**"
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: linuxmuster/lmndev-runner
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
ubuntu_version: ["24.04", "26.04"]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Check Ubuntu version availability
id: ubuntu
run: |
. ./config
VERSION="${{ matrix.ubuntu_version }}"
if docker pull "ubuntu:${VERSION}" >/dev/null 2>&1; then
echo "tag=${VERSION}" >> "$GITHUB_OUTPUT"
else
echo "WARNING: ubuntu:${VERSION} not available, using fallback: ${UBUNTU_FALLBACK}"
echo "tag=${UBUNTU_FALLBACK}" >> "$GITHUB_OUTPUT"
fi
- name: Determine image tags
id: tags
run: |
. ./config
VERSION="${{ matrix.ubuntu_version }}"
TAGS="${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${VERSION}"
if [ "${VERSION}" = "${UBUNTU_VERSION}" ]; then
TAGS="${TAGS},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest"
fi
echo "tags=${TAGS}" >> "$GITHUB_OUTPUT"
- name: Collect build dependencies and download linuxmuster-common
run: bash collect-deps.sh
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: .
push: true
tags: ${{ steps.tags.outputs.tags }}
build-args: |
UBUNTU_VERSION=${{ steps.ubuntu.outputs.tag }}
cache-from: type=gha,scope=ubuntu-${{ matrix.ubuntu_version }}
cache-to: type=gha,mode=max,scope=ubuntu-${{ matrix.ubuntu_version }}
- name: Remove temporary files
if: always()
run: rm -f deps.txt linuxmuster-common.deb