-
Notifications
You must be signed in to change notification settings - Fork 0
129 lines (113 loc) · 3.76 KB
/
docker.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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: docker
on:
push:
branches:
- "master"
jobs:
docker:
strategy:
matrix:
chain:
# TODO: make it dynamic
- axone
- chihuahua
- govgen
- juno
- ki
- nolus
continue-on-error: true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-go@v3
with:
cache: true
cache-dependency-path: "**/build.yaml"
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Go Build Cache for Docker
uses: actions/cache@v4
with:
path: |
go-build-cache
go-mod-cache
key: ${{ runner.os }}-go-build-cache-${{ hashFiles('**/build.yaml') }}
restore-keys: |
${{ runner.os }}-go-build-cache
- name: inject go-cache into docker
uses: reproducible-containers/[email protected]
with:
cache-map: |
{
"go-build-cache": "/root/.cache/go-build",
"go-mod-cache": "/go/pkg/mod"
}
- name: Login to GitHub Container Registry
uses: docker/[email protected]
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Get version
id: version
uses: mikefarah/yq@master
with:
cmd: yq -r '.version' './${{ matrix.chain }}/build.yaml'
- name: Get go_version
id: go_version
uses: mikefarah/yq@master
with:
cmd: yq -r '.go_version' './${{ matrix.chain }}/build.yaml'
- name: Get chain_repository
id: chain_repository
uses: mikefarah/yq@master
with:
cmd: yq -r '.chain_repository' './${{ matrix.chain }}/build.yaml'
- name: Get daemon_name
id: daemon_name
uses: mikefarah/yq@master
with:
cmd: yq -r '.daemon_name' './${{ matrix.chain }}/build.yaml'
- name: Get daemon_home
id: daemon_home
uses: mikefarah/yq@master
with:
cmd: yq -r '.daemon_home' './${{ matrix.chain }}/build.yaml'
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/${{ matrix.chain }}
tags: |
type=raw,value=latest
type=raw,value=${{ steps.version.outputs.result }}
- name: Check if image already exist
id: image_exists
continue-on-error: true
uses: cloudposse/[email protected]
with:
image_name: "${{ github.repository }}/${{ matrix.chain }}"
registry: ghcr.io
tag: "${{ steps.version.outputs.result }}"
# TODO: Check if the directory have a custom Dockerfile
# in that case, build a different image
- name: Build and push
uses: docker/build-push-action@v3
if: "steps.image_exists.outcome == 'failure'"
with:
file: "./Dockerfile"
context: ./${{ matrix.chain }}
build-args: |
CHAIN_NAME=${{ matrix.chain }}
VERSION=${{ steps.version.outputs.result }}
GO_VERSION=${{ steps.go_version.outputs.result }}
CHAIN_REPO=${{ steps.chain_repository.outputs.result }}
DAEMON_NAME=${{ steps.daemon_name.outputs.result }}
DAEMON_HOME=${{ steps.daemon_home.outputs.result }}
push: ${{ github.event_name != 'pull_request' }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}