-
Notifications
You must be signed in to change notification settings - Fork 39
129 lines (113 loc) · 4.28 KB
/
build_image_ghcr.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Build ghcr.io image
on:
push:
branches: [ 'main', '*dev*', '*alpha*', '*beta*', '*rc*' ]
tags:
workflow_dispatch:
inputs:
commit_sha:
description: 'Commit SHA to build'
required: true
jobs:
build-amd64-image-to-ghcr:
runs-on: ubuntu-22.04
env:
REGISTRY: 'ghcr.io/'
IMAGE_NAME: axon
# If you specify the access for any of these scopes, all of those that are not specified are set to none.
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.commit_sha || '' }}
# Extract metadata (tags, labels) for the Docker image
# https://github.com/docker/metadata-action
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
flavor: |
latest=auto
tags: |
type=ref,event=tag
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmm'}}
type=ref,event=branch,suffix=-{{sha}}
# minimal (short sha)
type=sha,enable=true,prefix=sha-,format=short
- name: Echo steps.meta.outputs.bake-file
run: cat ${{ steps.meta.outputs.bake-file }}
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Github resgistry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push image to ${{ env.REGISTRY }}${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Check versions of the binaries in ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
if: ${{ github.event_name != 'pull_request' }}
env:
IMAGE: ${{ fromJSON(steps.meta.outputs.json).tags[0] }}
run: |
docker run --rm ${{ env.IMAGE }} /app/axon --version
- name: Record image info to the outputs of this job
id: result
run: |
echo "image_name=`echo ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | awk -F ':' '{print $1}'`" >> $GITHUB_OUTPUT
echo "image_tag=`echo ${{ fromJSON(steps.meta.outputs.json).tags[0] }} | awk -F ':' '{print $NF}'`" >> $GITHUB_OUTPUT
# Map the meta step outputs to this job outputs
outputs:
image_name: ${{ steps.result.outputs.image_name }}
image_tag: ${{ steps.result.outputs.image_tag }}
test-in-docker-compose:
needs: build-amd64-image-to-ghcr
runs-on: ubuntu-22.04
defaults:
run:
working-directory: devtools/chain
steps:
- name: Checkout devtools/chain
uses: actions/checkout@v4
with:
sparse-checkout: |
devtools/chain
devtools/ci/scripts/helper.js
- name: Modify the Axon image of in devtools/chain/docker-compose.yml
env:
AXON_IMAGE: "${{ needs.build-amd64-image-to-ghcr.outputs.image_name }}:${{ needs.build-amd64-image-to-ghcr.outputs.image_tag }}"
uses: mikefarah/[email protected]
with:
cmd: yq -i '.services.axon.image = "${{ env.AXON_IMAGE }}"' 'devtools/chain/docker-compose.yml'
- name: Review devtools/chain/docker-compose.yml
run: |
echo "====== devtools/chain/docker-compose.yml ======"
cat docker-compose.yml
echo "==============================================="
docker -v
- name: Run docker compose (v2) up and check the Axon node's health
run: |
echo "start containers in detached mode and wait for them to become healthy"
docker compose up -d --wait
docker compose ps
docker compose logs --tail 6
npx zx <<'EOF'
import { waitXBlocksPassed } from '../ci/scripts/helper.js'
await retry(3, '6s', () => waitXBlocksPassed('http://127.0.0.1:8000', 2))
EOF
timeout-minutes: 2