fix(ci): update the concurrency strategy (#1461) #94
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build ghcr.io image | |
on: | |
push: | |
branches: [ 'main', '*docker*', '*dev*' ] | |
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 | |
# 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 waitXBlocksPassed('http://127.0.0.1:8000', 2); | |
EOF | |
timeout-minutes: 2 |