-
Notifications
You must be signed in to change notification settings - Fork 1
119 lines (116 loc) · 4.47 KB
/
container-build-and-push.yaml
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
---
name: Container build and push
run-name: Build ${{ inputs.docker_build_arg_package }} container image
permissions:
actions: write
contents: read
on:
workflow_call:
inputs:
docker_build_arg_package:
description: >
Value of `PACKAGE` to pass to `--build-args`. Expected to
be one of `entropy` or `entropy-tss`.
type: string
required: true
git_ref_basename:
description: Last portion of the Git ref, like `basename(1)`.
type: string
required: true
secrets:
DOCKER_HUB_USERNAME:
description: Username with which to log in to Docker Hub.
required: true
DOCKER_HUB_CI_TOKEN:
description: >
Docker Hub Personal Access Token (PAT) used as a password
with which to log in to Docker Hub.
required: true
CI_MACHINE_USER_TOKEN:
description: Fine-grained GitHub Personal Access Token specific for CI.
required: true
jobs:
build:
name: Build and upload ${{ inputs.docker_build_arg_package }} binary
runs-on: core-build-runner
steps:
- uses: actions/checkout@v4
# Occasionally our builds will run out of free hard disk space.
# This next GitHub Action purports to help clear space for runs.
- name: Free disk space (Ubuntu)
uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: false
docker-images: false
- name: Create temporary directories
run: |
mkdir ${{ runner.temp }}/bin
mkdir ${{ runner.temp}}/artifacts
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: entropyxyz/${{ inputs.docker_build_arg_package }}
tags: |
type=schedule
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=sha,format=long
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Builder
uses: docker/setup-buildx-action@v3
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_CI_TOKEN }}
- name: Build and push ${{ inputs.docker_build_arg_package }} container image
id: docker-build
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
build-args: |
PACKAGE=${{ inputs.docker_build_arg_package }}
secrets: |
credentials=${{ secrets.CI_MACHINE_USER_TOKEN }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
push: true
- name: Export plain binaries from built images
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
build-args: |
PACKAGE=${{ inputs.docker_build_arg_package }}
secrets: |
credentials=${{ secrets.CI_MACHINE_USER_TOKEN }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.meta.outputs.tags }}
outputs: |
type=local,dest=${{ runner.temp }}/bin
- name: Disambiguate binaries by platform
id: artifacts
run: |
dirname=${{ runner.temp }}/bin
refname=${{ inputs.git_ref_basename }}
package=${{ inputs.docker_build_arg_package }}
artifact_dir=${{ runner.temp }}/artifacts
for platform in linux_amd64 linux_arm64; do
cp ${dirname}/${platform}/usr/local/bin/${package} ${artifact_dir}/${package}_${refname}_${platform}
done
- name: Create genesis runtime bytecode artifact
if: inputs.docker_build_arg_package == 'entropy'
run: |
${{ runner.temp }}/artifacts/${{ inputs.docker_build_arg_package }}_${{ inputs.git_ref_basename }}_linux_amd64 \
build-spec --chain testnet \
> ${{ runner.temp }}/artifacts/${{ inputs.docker_build_arg_package }}-chain-spec-${{ inputs.git_ref_basename }}-${{ github.sha }}.json
- name: Upload ${{ inputs.docker_build_arg_package }} binary artifact
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.docker_build_arg_package}}_${{ inputs.git_ref_basename }}
path: ${{ runner.temp }}/artifacts/${{ inputs.docker_build_arg_package }}*
if-no-files-found: error
retention-days: 5