-
Notifications
You must be signed in to change notification settings - Fork 14
98 lines (86 loc) · 3.82 KB
/
image-build.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
## Github workflow to build a multiarch docker image from pre-built binaries
name: Docker Image (Binary)
on:
workflow_dispatch:
schedule:
- cron: '0 2 * * *'
push:
tags:
- '*'
## Define which docker arch to build for
env:
docker_platforms: "linux/amd64"
docker-org: blockstack
latest_release: $(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
concurrency:
group: docker-image-${{ github.head_ref || github.ref || github.run_id }}
## Always cancel duplicate jobs
cancel-in-progress: true
run-name: "Build and Release sBTC Signer ${{ github.ref_name }} Docker Image"
jobs:
image:
name: Build Image
strategy:
fail-fast: false
## Build a maximum of 2 images for if / when this is extended
## for more distribution types.
max-parallel: 2
matrix:
dist:
- debian
docker_target:
- signer
- blocklist-client
runs-on: ubuntu-latest
steps:
## Setup Docker for the builds
- name: Docker setup
id: docker_setup
uses: stacks-network/actions/docker@main
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
# Fetch the latest release tag and put into environment variables under
# the key `latest_release`.
- name: Get latest release tag
id: get_latest_release
run: |
latest_release=$(curl -s https://api.github.com/repos/${{ github.repository }}/releases/latest | jq -r .tag_name)
echo "latest_release=$latest_release" >> $GITHUB_ENV
## Checkout the branch of the release provided.
## This requires that a release branch exists for the tag.
- name: Checkout
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
## if the repo owner is not `stacks-network`, default to a docker-org of the repo owner (i.e. github user id)
## this allows forks to run the docker push workflows without having to hardcode a dockerhub org (but it does require docker hub user to match github username)
- name: Set Local env vars
id: set_env
if: |
github.repository_owner != 'stacks-network'
run: |
echo "docker-org=${{ github.repository_owner }}" >> "$GITHUB_ENV"
## Set docker metatdata
## - depending on the matrix.dist, different tags will be enabled
## ex. debian will have this tag: `type=ref,event=tag,enable=${{ matrix.dist == 'debian' }}`
- name: Docker Metadata ( ${{ matrix.dist }} )
id: docker_metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 # v5.5.1
with:
images: |
${{ env.docker-org }}/sbtc
tags: |
type=raw,value=${{ matrix.docker_target }}-${{ github.ref_name }}-${{ matrix.dist }}
type=raw,value=${{ matrix.docker_target }}-${{ github.ref_name }},enable=${{ matrix.dist == 'debian' }}
type=raw,value=${{ matrix.docker_target }}-latest,enable=${{ env.latest_release == github.ref_name && matrix.dist == 'debian' }}
type=raw,value=${{ matrix.docker_target }}-latest-${{ matrix.dist }},enable=${{ env.latest_release == github.ref_name }}
## Build docker image for release
- name: Build and Push ( ${{ matrix.dist }} ${{ matrix.docker_target }} )
id: docker_build
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
file: ./.github/actions/dockerfiles/Dockerfile.${{ matrix.docker_target }}.${{ matrix.dist }}
platforms: ${{ env.docker_platforms }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
target: ${{ matrix.docker_target }}
push: true