-
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (66 loc) · 2.32 KB
/
reuse-build.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
name: Build
on:
workflow_call:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout git repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github container registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare BUILD.json
run: |
echo '{"version": "${{github.ref_name}}", "repository": "${{github.server_url}}/${{github.repository}}", "commit": "${{github.sha}}"}' > BUILD.json
cat BUILD.json
- name: Prepare docker tags for main image
id: docker_meta_main
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push main image
id: docker_build_main
uses: docker/build-push-action@v5
with:
context: .
push: true
target: main
tags: ${{ steps.docker_meta_main.outputs.tags }}
platforms: linux/amd64
labels: ${{ steps.docker_meta_main.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/buildcache
cache-to: type=registry,ref=ghcr.io/${{ github.repository }}/buildcache,mode=max
- name: Prepare docker tags for secondary daemon image
id: docker_meta_daemon
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/daemon
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Build and push secondary daemon image
id: docker_build_daemon
uses: docker/build-push-action@v5
with:
context: .
push: true
target: daemon
tags: ${{ steps.docker_meta_daemon.outputs.tags }}
platforms: linux/amd64
labels: ${{ steps.docker_meta_daemon.outputs.labels }}
cache-from: type=registry,ref=ghcr.io/${{ github.repository }}/buildcache