-
Notifications
You must be signed in to change notification settings - Fork 1
104 lines (91 loc) · 2.88 KB
/
Copy pathpublish-ghcr.yml
File metadata and controls
104 lines (91 loc) · 2.88 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
name: Container
# Build the ingot daemon image and publish it to GHCR on merges to main.
# Mirrors sprue's dev/prod pattern so smelt can pull a consistent
# ghcr.io/fil-forge/ingot:main (prod) and :main-dev (debug + dlv) pair.
# ingot has no releaser, so this is the PR build-check + publish-on-main
# half of sprue's workflow.
on:
push:
branches: [main]
pull_request:
branches: [main]
# Cancel in-progress runs on new pushes to the same ref.
concurrency:
group: container-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# Publish both prod and dev images on push to main.
# prod -> :main, :sha-<short>
# dev -> :main-dev, :sha-<short>-dev
publish-main:
name: Publish ${{ matrix.target }}
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
include:
- target: prod
suffix: ""
- target: dev
suffix: "-dev"
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- 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.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=main${{ matrix.suffix }}
type=sha,suffix=${{ matrix.suffix }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
target: ${{ matrix.target }}
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.target }}
cache-to: type=gha,scope=${{ matrix.target }},mode=max
# PR build check (no push) - both targets, single platform for speed.
build-check:
name: Build Check (${{ matrix.target }})
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
target: [dev, prod]
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build ${{ matrix.target }}
uses: docker/build-push-action@v7
with:
context: .
target: ${{ matrix.target }}
platforms: linux/amd64
push: false
cache-from: type=gha,scope=${{ matrix.target }}