-
Notifications
You must be signed in to change notification settings - Fork 526
103 lines (97 loc) · 3.18 KB
/
docker-build-production.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
# Runs when `release-*` branch is created or push changes into `release-*` branch.
name: Docker Build Production Release
on:
create:
push:
branches:
- release-**
paths-ignore:
- '**/README.md'
workflow_dispatch:
inputs:
branch:
description: Branch to build docker image (optional). Helpful to build docker image for release branches that don't have image
required: false
type: string
jobs:
clean-up-actions:
runs-on: ubuntu-latest
# Skip non-release branches
if: startsWith(github.ref_name, 'release-')
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
setup-matrix:
runs-on: ubuntu-latest
needs: clean-up-actions
outputs:
matrix: ${{ steps.docker-setup-matrix.outputs.matrix }}
version: ${{ steps.docker-setup-matrix.outputs.version }}
steps:
- uses: actions/checkout@v3
with:
submodules: recursive
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Setup Matrix
id: docker-setup-matrix
run: python .github/scripts/docker_setup_matrix.py ${{ github.event.inputs.branch || github.ref }}
build-image:
name: "Build docker image ${{ matrix.network }}"
runs-on: ubuntu-latest
needs: setup-matrix
strategy:
matrix: ${{fromJson(needs.setup-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.inputs.branch || github.ref }}
submodules: recursive
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
# list of Docker images to use as base name for tags
images: |
ghcr.io/acalanetwork/${{ matrix.network }}-node
# generate Docker tags based on the following events/attributes
tags: |
type=raw,value=${{ needs.setup-matrix.outputs.version || github.ref_name }}
type=ref,event=pr
type=sha
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
BUILD_ARGS=build-${{ matrix.network }}-release
GIT_COMMIT=${{ env.GITHUB_SHA }}
PROFILE=production
file: scripts/Dockerfile
cache-from: type=gha
cache-to: type=gha,mode=max
trigger:
needs: build-image
if: ${{ startsWith(github.ref_name, 'release-') }}
uses: ./.github/workflows/extrinsic-ordering-check-on-release.yml
secrets: inherit
with:
chain: ${{ matrix.network }}