-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
86 lines (79 loc) · 2.32 KB
/
devcontainer-image.yml
File metadata and controls
86 lines (79 loc) · 2.32 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
name: Build HugoBlox devcontainer image
on:
push:
branches: [main]
paths:
- ".devcontainer/base.Dockerfile"
- ".github/workflows/devcontainer-image.yml"
workflow_dispatch:
inputs:
hugo_versions:
description: "Comma-separated Hugo versions to build (e.g. 0.152.2,0.154.0)"
required: false
env:
IMAGE_NAME: ghcr.io/hugoblox/hugo-blox-dev
DEFAULT_HUGO_VERSION: 0.152.2
NODE_VERSION: 20
PNPM_VERSION: 10.14.0
jobs:
prepare-matrix:
runs-on: ubuntu-latest
outputs:
versions: ${{ steps.versions.outputs.matrix }}
steps:
- name: Select Hugo versions
id: versions
env:
VERSIONS: ${{ github.event.inputs.hugo_versions || env.DEFAULT_HUGO_VERSION }}
run: |
MATRIX=$(python - <<'PY'
import os, json
versions = [v.strip() for v in os.environ["VERSIONS"].split(",") if v.strip()]
print(json.dumps(versions))
PY
)
echo "matrix=${MATRIX}" >> "$GITHUB_OUTPUT"
build-and-push:
needs: prepare-matrix
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
fail-fast: false
matrix:
hugo: ${{ fromJson(needs.prepare-matrix.outputs.versions) }}
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Compute tags
id: tags
env:
HUGO_VERSION: ${{ matrix.hugo }}
run: |
TAGS="${IMAGE_NAME}:hugo${HUGO_VERSION}"
if [ "${HUGO_VERSION}" = "${DEFAULT_HUGO_VERSION}" ]; then
TAGS="${TAGS}\n${IMAGE_NAME}:latest"
fi
{
echo "list<<EOF"
printf "%b\n" "$TAGS"
echo "EOF"
} >> "$GITHUB_OUTPUT"
- name: Build and push image
uses: docker/build-push-action@v7
with:
context: .
file: .devcontainer/base.Dockerfile
push: true
build-args: |
HUGO_VERSION=${{ matrix.hugo }}
NODE_VERSION=${{ env.NODE_VERSION }}
PNPM_VERSION=${{ env.PNPM_VERSION }}
tags: ${{ steps.tags.outputs.list }}