forked from stacks-network/stacks-core
-
Notifications
You must be signed in to change notification settings - Fork 0
75 lines (67 loc) · 2.55 KB
/
image-build-source.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
## Github workflow to build a docker image from source
name: Docker Image (Source)
on:
workflow_dispatch:
workflow_call:
## Define which docker arch to build for
env:
docker_platforms: "linux/amd64"
docker-org: blockstack
concurrency:
group: docker-image-source-${{ github.head_ref || github.ref || github.run_id }}
## Always cancel duplicate jobs
cancel-in-progress: true
jobs:
## Runs anytime `ci.yml` runs or when manually called
image:
name: Build Image
runs-on: ubuntu-latest
strategy:
fail-fast: false
## Build a maximum of 2 images concurrently based on matrix.dist
max-parallel: 2
matrix:
dist:
- debian
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 }}
## 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
- name: Docker Metadata ( ${{matrix.dist}} )
id: docker_metadata
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81 #v5.5.1
with:
images: |
${{env.docker-org}}/${{ github.event.repository.name }}
${{env.docker-org}}/stacks-blockchain
tags: |
type=raw,value=${{ env.BRANCH_NAME }}
type=ref,event=pr
## Build docker image
- name: Build and Push ( ${{matrix.dist}} )
id: docker_build
uses: docker/build-push-action@2cdde995de11925a030ce8070c3d77a52ffcf1c0 # v5.3.0
with:
file: ./.github/actions/dockerfiles/Dockerfile.${{matrix.dist}}-source
platforms: ${{ env.docker_platforms }}
tags: ${{ steps.docker_metadata.outputs.tags }}
labels: ${{ steps.docker_metadata.outputs.labels }}
build-args: |
STACKS_NODE_VERSION=${{ env.GITHUB_SHA_SHORT }}
GIT_BRANCH=${{ env.GITHUB_REF_SHORT }}
GIT_COMMIT=${{ env.GITHUB_SHA_SHORT }}
TARGET_CPU=x86-64-v3
push: ${{ env.DOCKER_PUSH }}