-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (85 loc) · 2.77 KB
/
docker.yml
File metadata and controls
99 lines (85 loc) · 2.77 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
name: publish-image
concurrency:
group: publish-image-${{ github.event.workflow_run.head_branch || github.ref_name || 'manual' }}
cancel-in-progress: true
on:
workflow_dispatch:
# Dockerfile builds again but does not run tests so we only
# run this workflow after successful Go build-test
workflow_run:
workflows: ['build-test']
types: [completed]
branches: ['main']
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push-image:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
- module: broker
dockerfile: ./broker/Dockerfile
image: ghcr.io/${{ github.repository }}-broker
- module: illmock
dockerfile: ./illmock/Dockerfile
image: ghcr.io/${{ github.repository }}-illmock
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
# For workflow_run, build exactly the commit that completed build-test.
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
- name: Set up Go
uses: actions/setup-go@v6
with:
go-version: stable
cache-dependency-path: |
go.work.sum
${{ matrix.module }}/go.sum
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: xsltproc
version: 1.0
- name : Install sqlc
uses: sqlc-dev/setup-sqlc@v5
with:
sqlc-version: '1.25.0'
- name: Generate sources
run: make generate
- name: Log in to the Container registry
uses: docker/login-action@v4
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v6
with:
images: ${{ matrix.image }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=sha
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Build and push Docker image
uses: docker/build-push-action@v7
with:
context: .
file: ${{ matrix.dockerfile }}
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha,scope=${{ matrix.module }}
cache-to: type=gha,mode=max,scope=${{ matrix.module }}