-
Notifications
You must be signed in to change notification settings - Fork 39
106 lines (93 loc) · 3.12 KB
/
build-dockers.yml
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
name: Build Docker Images
on:
push:
branches:
- "**"
tags:
- "v*"
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: Build binaries
run: |
build/build.sh
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit any updated files
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "[skip ci] Commit changes from build-dockers action"
commit_options: "-S"
commit_user_email: ${{ vars.COMMIT_USER }}
- name: Cache build output
uses: actions/cache/save@v4
with:
path: build
key: build-dockers-${{ github.sha }}
build-publish:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
include:
- image: ghcr.io/hakwerk/labca-gui
dockerfile: build/Dockerfile-gui
label: org.opencontainers.image.title=labca-gui
- image: ghcr.io/hakwerk/labca-boulder
dockerfile: build/Dockerfile-boulder
label: org.opencontainers.image.title=labca-boulder
- image: ghcr.io/hakwerk/labca-control
dockerfile: build/Dockerfile-control
label: org.opencontainers.image.title=labca-control
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}
- name: Restore build output
uses: actions/cache/restore@v4
with:
path: build
key: build-dockers-${{ github.sha }}
- name: Set up docker buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ matrix.image }}
labels: ${{ matrix.label }}
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=match,pattern=v(.*),group=1
type=edge,enable=${{ github.ref == format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=branch,enable=${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) }}
type=ref,event=pr
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.ACTION_PAT }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: build
file: ${{ matrix.dockerfile }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}