-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (139 loc) · 4.68 KB
/
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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
---
name: Build
on:
push:
branches:
- master
tags:
- v*
paths-ignore:
- '**.md'
pull_request:
# The branches below must be a subset of the branches above
branches:
- master
paths-ignore:
- '**.md'
schedule:
- cron: '00 03 * * *'
workflow_dispatch:
permissions:
contents: read
packages: write
env:
DOCKERHUB_TEST_TAG: ci-test
jobs:
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 720
strategy:
fail-fast: false
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Fetch full annotated tags metadata
run: git fetch --force --tags
- name: Configure DockerHub Publish Image Tag
run: |
github_ref="${{github.ref}}"
if [[ "${github_ref:?}" == refs/tags/v* ]]; then
echo "DOCKERHUB_PUBLISH_TAG=${github_ref#refs/tags/v}" >> $GITHUB_ENV
else
echo "DOCKERHUB_PUBLISH_TAG=${{github.ref_name}}" >> $GITHUB_ENV
fi
- name: Set up makesystem
run: make makesystem_install
- name: Disable Experimental Docker Daemon
run: |
sudo jq '.experimental = false' < /etc/docker/daemon.json > /tmp/docker.json
sudo mv /tmp/docker.json /etc/docker/daemon.json
sudo cat /etc/docker/daemon.json
sudo service docker restart
docker version
docker info
- name: Set Up Docker Build Kit Daemon Flags
id: docker_buildkitd_flags
run: make github_dump_docker_buildkitd_flags
- name: Set Up Docker Entitlements
id: docker_entitlements
run: make github_dump_docker_entitlements
- name: Set Up Docker Build Args
id: docker_build_args
run: make github_dump_docker_build_args
- name: Set Workflow Env vars
run: make github_env_vars >> $GITHUB_ENV
- name: Set up QEMU for Docker
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
buildkitd-flags: ${{ steps.docker_buildkitd_flags.outputs.buildkitd_flags }}
- name: Login to DockerHub
uses: docker/login-action@v3
if: >-
(
github.event_name != 'pull_request'
) && (
github.ref_name == 'master' ||
startsWith(github.ref, 'refs/tags/v')
)
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build amd64 Docker image locally
uses: docker/build-push-action@v5
with:
context: .
load: true
push: false
tags: ${{ env.DOCKERHUB_REPO_NAME }}:${{ env.DOCKERHUB_TEST_TAG }}
build-args: ${{ steps.docker_build_args.outputs.build_args }}
allow: ${{ steps.docker_entitlements.outputs.entitlements }}
- name: Test the local amd64 Docker image
run: |
IMAGE_TAG=${{ env.DOCKERHUB_TEST_TAG }} make test
- name: Build docker images for all platforms (with registry pushes)
uses: docker/build-push-action@v5
if: >-
(
github.event_name != 'pull_request'
) && (
github.ref_name == 'master' ||
startsWith(github.ref, 'refs/tags/v')
)
with:
context: .
platforms: ${{env.IMAGE_SUPPORTED_DOCKER_PLATFORMS}}
push: true
provenance: mode=max
sbom: true
tags: |
${{ env.DOCKERHUB_REPO_NAME }}:${{ env.DOCKERHUB_PUBLISH_TAG }}
${{ env.GHCR_REPO_NAME }}:${{ env.DOCKERHUB_PUBLISH_TAG }}
build-args: ${{ steps.docker_build_args.outputs.build_args }}
allow: ${{ steps.docker_entitlements.outputs.entitlements }}
- name: Build docker images for all platforms (no registry pushes)
uses: docker/build-push-action@v5
if: >-
(
github.event_name == 'pull_request'
) || (
github.ref_name != 'master' &&
!startsWith(github.ref, 'refs/tags/v')
)
with:
context: .
platforms: ${{env.IMAGE_SUPPORTED_DOCKER_PLATFORMS}}
push: false
tags: ${{ env.DOCKERHUB_REPO_NAME }}:${{ env.DOCKERHUB_TEST_TAG }}
build-args: ${{ steps.docker_build_args.outputs.build_args }}
allow: ${{ steps.docker_entitlements.outputs.entitlements }}