-
Notifications
You must be signed in to change notification settings - Fork 85
109 lines (101 loc) · 4 KB
/
build-docker.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
name: Docker Build
on:
push:
branches: [main, 'release-v**']
pull_request:
paths:
- ".github/workflows/build-docker.yml"
- "Dockerfile"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.head.label || github.head_ref || github.ref }}${{ github.ref == '/refs/heads/main' && github.sha || 'false' }}
cancel-in-progress: true
env:
RUST_TOOLCHAIN: "1.66"
jobs:
docker:
strategy:
matrix:
target: [ release, test ]
runs-on: ubuntu-latest-8-cores
env:
WORKFLOW_TAG: ${{ github.event.inputs.docker_tag }}
steps:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac #v4
with:
fetch-depth: 0
- name: Free space
# https://github.com/actions/runner-images/issues/2840#issuecomment-1284059930
run: |
sudo rm -rf /usr/share/dotnet
# sudo rm -rf "/usr/local/share/boost"
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- name: check available docker space
run: |
docker volume ls
df -h
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 #v3
- name: DockerHub Login
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
- run: echo "NOW=$(date -u +%y-%m-%d)" >> $GITHUB_ENV
- name: Setup docker metadata
id: meta
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 #v5
with:
images: centrifugeio/centrifuge-chain
flavor: |
suffix=-${{ env.NOW }}
# latest=auto is already default, but the logic needs a value at the end and '' isn't valid
${{ matrix.target == 'test' && 'prefix=test-' || 'latest=auto' }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}
type=edge
- name: Configure sccache
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 #v6
with:
script: |
core.exportVariable('ACTIONS_CACHE_URL', process.env.ACTIONS_CACHE_URL || '');
core.exportVariable('ACTIONS_RUNTIME_TOKEN', process.env.ACTIONS_RUNTIME_TOKEN || '');
- name: Build and push centrifugeio/centrifuge-chain
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5
# env:
# BUILDKIT_PROGRESS: plain
# DOCKER_BUILDKIT: 1
with:
context: .
file: ./docker/centrifuge-chain/Dockerfile
build-args: |
FEATURES=${{ matrix.target == 'test' && 'fast-runtime' || '' }}
# SCCACHE_GHA_ENABLED="true"
# RUSTC_WRAPPER=sccache
push: ${{ github.ref == '/refs/heads/main' && true || false }}
tags: ${{ steps.meta.outputs.tags }}
# Cache options:
# https://docs.docker.com/build/ci/github-actions/cache/
cache-from: type=gha
# cache-from: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}
# https://docs.docker.com/build/cache/backends/inline/
cache-to: type=gha, mode=max
# cache-to: type=registry,ref=centrifugeio/centrifuge-chain:${{ github.ref }}, mode=max
- name: Update DockerHub descriptions
if: contains(github.ref, 'refs/tags/release-v')
uses: peter-evans/dockerhub-description@dc67fad7001ef9e8e3c124cb7a64e16d0a63d864 #v3.4.2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
repository: centrifuge/centrifuge-chain
short-description: ${{ github.event.repository.description }}
enable-url-completion: true
- if: failure()
name: Check available space after build failed
run: |
docker volume ls
df -h