-
Notifications
You must be signed in to change notification settings - Fork 41
81 lines (71 loc) · 2.46 KB
/
preview-build.yml
File metadata and controls
81 lines (71 loc) · 2.46 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
name: 🔬 Preview build
# Manual-dispatch image build for testing branches before they land on dev.
# Triggering on `fix/abort-kills-merge-and-cleanup-race` publishes
# `ghcr.io/mpecan/gha-cache-server:preview-<short-sha>` so a downstream
# deployment can pin it by digest. No lint/test gate — this is explicitly
# for in-cluster validation of in-flight patches; the full CI still runs on
# push and on the eventual PR.
on:
workflow_dispatch:
inputs:
tag-suffix:
description: "Optional extra tag suffix (appended after the short sha)"
required: false
default: ""
concurrency:
group: preview-build-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: 🚀 Build and push preview
permissions:
packages: write
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Compute tags
id: tags
run: |
SHORT_SHA=$(git rev-parse --short HEAD)
BRANCH_SLUG=$(echo "${{ github.ref_name }}" | tr '/' '-')
SUFFIX="${{ inputs.tag-suffix }}"
TAGS="ghcr.io/${{ github.repository }}:preview-${SHORT_SHA}"
TAGS="${TAGS}
ghcr.io/${{ github.repository }}:preview-${BRANCH_SLUG}"
if [ -n "${SUFFIX}" ]; then
TAGS="${TAGS}
ghcr.io/${{ github.repository }}:preview-${SHORT_SHA}-${SUFFIX}"
fi
{
echo "tags<<EOF"
echo "$TAGS"
echo "EOF"
echo "short_sha=${SHORT_SHA}"
} >> "$GITHUB_OUTPUT"
- name: Login to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push
id: build
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.tags.outputs.tags }}
build-args: |
BUILD_HASH=${{ steps.tags.outputs.short_sha }}
- name: Print digest
run: |
echo "Image digest: ${{ steps.build.outputs.digest }}"
echo
echo "Pin in a deployment with:"
echo " image: ghcr.io/${{ github.repository }}@${{ steps.build.outputs.digest }}"