-
-
Notifications
You must be signed in to change notification settings - Fork 50
76 lines (65 loc) · 2.02 KB
/
Copy pathimage.yml
File metadata and controls
76 lines (65 loc) · 2.02 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
name: Build Image (edge)
# Every merge to main pushes an immutable sha-tagged image plus a moving
# `edge` tag. Nothing deploys from here — deploys happen on release publish
# (deploy.yml). This keeps every merge one dispatch away from prod (or from
# a rollback) and keeps the buildx cache warm so release builds are fast.
#
# workflow_dispatch builds ANY ref (e.g. a feature branch for the beta
# slice) as a sha-only image — the `edge` tag is guarded to push events
# so branch builds can never steal it from main.
on:
push:
branches:
- main
paths-ignore:
- '**/*.md'
- '**/*.rst'
- 'docs/**'
workflow_dispatch:
permissions:
contents: read
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GHCR_PAT }}
- name: Short sha
id: sha
run: echo "short=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=edge,enable=${{ github.event_name == 'push' }}
type=sha,prefix=,format=short
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
APP_VERSION=${{ steps.sha.outputs.short }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64