-
-
Notifications
You must be signed in to change notification settings - Fork 0
172 lines (158 loc) · 5.72 KB
/
Copy pathdocker.yml
File metadata and controls
172 lines (158 loc) · 5.72 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# Copyright (C) 2024-2026 jango_blockchained
# SPDX-License-Identifier: AGPL-3.0-only
# Build and push AXIS container images to GHCR.
#
# Images (owner from github.repository_owner):
# ghcr.io/<owner>/axis:pwa
# ghcr.io/<owner>/axis:pwa-latest (main pushes)
# ghcr.io/<owner>/axis:pwa-v<version> (release; e.g. pwa-v2.0.21)
# ghcr.io/<owner>/axis:pwa-nginx (when building all/release)
name: Docker
on:
push:
# Do not path-filter `push`: GitHub applies push.paths to tag pushes too,
# which would skip GHCR version tags when the release commit only touches
# CHANGELOG / packages/cli / worker.
branches: [main]
tags: ['v*']
pull_request:
paths:
- 'Dockerfile'
- 'docker/**'
- 'docker-bake.hcl'
- 'docker-compose.yml'
- 'package.json'
- 'bun.lock'
- 'src/**'
- 'public/**'
- '.github/workflows/docker.yml'
workflow_dispatch:
inputs:
push:
description: 'Push images to GHCR'
type: boolean
default: true
targets:
description: 'Bake group/target'
type: choice
options:
- pwa
- all
- release
default: all
concurrency:
group: docker-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
packages: write
jobs:
build:
name: Bake images
runs-on: ubuntu-latest
timeout-minutes: 90
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Meta
id: meta
run: |
SHA_SHORT="${GITHUB_SHA::7}"
echo "sha_short=${SHA_SHORT}" >> "$GITHUB_OUTPUT"
if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then
TAG="${GITHUB_REF#refs/tags/v}"
TARGET="release"
MULTIARCH=true
else
TAG="latest"
TARGET="${{ github.event.inputs.targets || 'all' }}"
# `all` includes :local tags that bake-action --push tries to
# push to docker.io. GHCR push must use the release group.
if [[ "${{ github.event_name }}" != "pull_request" && "${TARGET}" == "all" ]]; then
TARGET="release"
fi
MULTIARCH=false
fi
echo "tag=${TAG}" >> "$GITHUB_OUTPUT"
echo "bake_target=${TARGET}" >> "$GITHUB_OUTPUT"
echo "multiarch=${MULTIARCH}" >> "$GITHUB_OUTPUT"
VER=$(node -p "require('./package.json').version" 2>/dev/null || echo "2.0.0")
echo "version=${VER}" >> "$GITHUB_OUTPUT"
PUSH=false
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
if [[ "${{ github.event_name }}" != "workflow_dispatch" || "${{ inputs.push }}" == "true" ]]; then
PUSH=true
fi
fi
echo "push=${PUSH}" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
if: steps.meta.outputs.multiarch == 'true'
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GHCR
if: steps.meta.outputs.push == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Bake (push)
if: steps.meta.outputs.push == 'true'
uses: docker/bake-action@v6
env:
TAG: ${{ steps.meta.outputs.tag }}
GIT_SHA: ${{ steps.meta.outputs.sha_short }}
VERSION: ${{ steps.meta.outputs.version }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME: axis
with:
files: |
./docker-bake.hcl
targets: ${{ steps.meta.outputs.bake_target }}
push: true
set: |
*.args.GIT_SHA=${{ steps.meta.outputs.sha_short }}
*.args.VERSION=${{ steps.meta.outputs.version }}
*.args.BUN_VERSION=1.3.14
*.cache-from=type=gha,scope=axis-docker
*.cache-to=type=gha,mode=max,scope=axis-docker
${{ steps.meta.outputs.multiarch != 'true' && '*.platform=linux/amd64' || '' }}
- name: Bake (PR / no-push load)
if: steps.meta.outputs.push != 'true'
uses: docker/bake-action@v6
env:
TAG: ${{ steps.meta.outputs.tag }}
GIT_SHA: ${{ steps.meta.outputs.sha_short }}
VERSION: ${{ steps.meta.outputs.version }}
REGISTRY: ghcr.io/${{ github.repository_owner }}
IMAGE_NAME: axis
with:
files: |
./docker-bake.hcl
# release group requires push; fall back to all for PR validation
targets: ${{ steps.meta.outputs.bake_target == 'release' && 'all' || steps.meta.outputs.bake_target }}
load: true
set: |
*.args.GIT_SHA=${{ steps.meta.outputs.sha_short }}
*.args.VERSION=${{ steps.meta.outputs.version }}
*.args.BUN_VERSION=1.3.14
*.cache-from=type=gha,scope=axis-docker
*.cache-to=type=gha,mode=max,scope=axis-docker
*.platform=linux/amd64
*.output=type=docker
- name: Summary
if: always()
run: |
{
echo "## Docker bake"
echo ""
echo "| Field | Value |"
echo "|-------|-------|"
echo "| Target | \`${{ steps.meta.outputs.bake_target }}\` |"
echo "| Push | \`${{ steps.meta.outputs.push }}\` |"
echo "| Tag | \`${{ steps.meta.outputs.tag }}\` |"
echo "| SHA | \`${{ steps.meta.outputs.sha_short }}\` |"
echo "| Version | \`${{ steps.meta.outputs.version }}\` |"
echo "| Image | \`ghcr.io/${{ github.repository_owner }}/axis:pwa\` |"
} >> "$GITHUB_STEP_SUMMARY"