-
Notifications
You must be signed in to change notification settings - Fork 4
171 lines (154 loc) · 5.29 KB
/
build_dockers_workflow.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
162
163
164
165
166
167
168
169
170
171
---
name: Build docker image - workflow_call/on-demand
'on':
workflow_call:
secrets:
DOCKER_PROVIDER:
required: true
DOCKER_USERNAME:
required: true
DOCKER_PASSWORD:
required: true
DOCKER_REPO:
required: true
inputs:
arch:
type: string
default: x86-64
features:
type: string
default: safe
version:
type: string
description: 'build tag/version'
tag_alias:
type: string
description: 'build tag alias'
platforms:
type: string
# linux/arm64, linux/amd64
default: linux/amd64
env:
IMAGE_NAME: dan-testing
TARI_REPO: tari-project/tari
TARI_BRANCH: feature-dan2
TARI-DAN_REPO: tari-project/tari-dan
TARI-DAN_BRANCH: development
TARI-CONNECTOR_REPO: tari-project/tari-connector
TARI-CONNECTOR_BRANCH: development
jobs:
docker_build:
runs-on: ubuntu-22.04
permissions:
packages: write
steps:
- name: checkout dan-testing
uses: actions/checkout@v4
with:
path: sources/dan-testing
- name: checkout tari
uses: actions/checkout@v4
with:
repository: ${{ env.TARI_REPO }}
ref: ${{ env.TARI_BRANCH }}
path: sources/tari
- name: checkout tari-dan
uses: actions/checkout@v4
with:
repository: ${{ env.TARI-DAN_REPO }}
ref: ${{ env.TARI-DAN_BRANCH }}
path: sources/tari-dan
- name: checkout tari-connector
uses: actions/checkout@v4
with:
repository: ${{ env.TARI-CONNECTOR_REPO }}
ref: ${{ env.TARI-CONNECTOR_BRANCH }}
path: sources/tari-connector
- name: environment setup
shell: bash
run: |
cp -v sources/dan-testing/docker_rig/cross-compile-aarch64.sh sources/
if [ -z "${{ inputs.version }}" ]; then
echo "Get dan-testing version"
TARI_SOURCE_ROOT="sources/dan-testing/"
VBRANCH=$(git --git-dir ${TARI_SOURCE_ROOT}/.git branch --show-current)
VSHA_SHORT=$(git --git-dir ${TARI_SOURCE_ROOT}/.git rev-parse --short HEAD)
VERSION="${VBRANCH}_$(date -u '+%Y%m%d')_${VSHA_SHORT}"
else
VERSION=${{ inputs.version }}
fi
echo "Setting ${VERSION} as docker tag"
echo "VERSION=${VERSION}" >> $GITHUB_ENV
if [ ! -z "${{ inputs.tag_alias }}" ]; then
echo "Setup tag_alias"
echo "TAG_ALIAS=${{ secrets.DOCKER_PROVIDER }}/${{ secrets.DOCKER_REPO }}/${{ env.IMAGE_NAME }}:${{ inputs.tag_alias }}" >> $GITHUB_ENV
fi
- name: Set up QEMU for Docker
uses: docker/setup-qemu-action@v3
- 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: |
#name/${{ env.IMAGE_NAME }}
#ghcr.io/${{ github.repository }}
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
tags: |
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=sha
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
#username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to Docker Image Provider
uses: docker/login-action@v3
with:
registry: ${{ secrets.DOCKER_PROVIDER }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: false
# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
# android=14GB - dotnet=2GB - haskell=0B
# large-packages=5GB - docker-images=6GB - swap-storage=4GB
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false
- name: Docker image build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./sources/
file: ./sources/dan-testing/docker_rig/${{ env.IMAGE_NAME }}.Dockerfile
platforms: ${{ inputs.platforms }}
push: true
provenance: false
# cache-from: type=gha
# cache-to: type=gha,mode=max
build-args: |
VERSION=${{ env.VERSION }}
ARCH=${{ inputs.arch }}
${{ env.DOCKER_SUBTAG }}
tags: |
${{ steps.meta.outputs.tags }}
${{ secrets.DOCKER_PROVIDER }}/${{ secrets.DOCKER_REPO }}/${{ env.IMAGE_NAME }}:${{ env.VERSION }}
${{ env.TAG_ALIAS }}
labels: ${{ steps.meta.outputs.labels }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}