Skip to content

Publish Docker

Publish Docker #148

name: Publish Docker
on:
workflow_dispatch:
inputs:
client_tag:
description: moonbeam client tag (ex. v0.8.3) to publish on docker
required: true
overrides_branch:
description: runtime overrides branch (default master)
required: true
default: "master"
jobs:
docker-moonbeam-tracing:
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.get-sha.outputs.sha }}
sha4: ${{ steps.get-sha.outputs.sha4 }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.overrides_branch }}
- name: Get Sha
id: get-sha
run: |
echo "sha=$(git log -1 --format="%H")" >> "$GITHUB_OUTPUT"
echo "sha4=$(git log -1 --format="%H" | cut -c1-4)" >> "$GITHUB_OUTPUT"
- name: Get last tracing runtime spec version
id: get-last-spec-version
run: |
INTEGER_REGEX='^[0-9]+$'
MAX=0
cd tracing
for D in *; do
if [[ "${D}" =~ $INTEGER_REGEX ]] ; then
if [ "${D}" -gt "$MAX" ]; then
MAX=${D}
fi
fi
done
echo "last_spec_version=$MAX" >> "$GITHUB_OUTPUT"
echo "last_spec_version: $MAX"
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=moonbeamfoundation/moonbeam-tracing
DOCKER_TAG="${DOCKER_IMAGE}:${{ github.event.inputs.client_tag }}-${{ steps.get-last-spec-version.outputs.last_spec_version }}-${{ steps.get-sha.outputs.sha4 }}"
DOCKER_LATEST_TAG="${DOCKER_IMAGE}:${{ github.event.inputs.client_tag }}-${{ steps.get-last-spec-version.outputs.last_spec_version }}-latest"
echo "docker_tag=${DOCKER_TAG}" >> "$GITHUB_OUTPUT"
echo "docker_latest_tag=${DOCKER_LATEST_TAG}" >> "$GITHUB_OUTPUT"
echo "created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> "$GITHUB_OUTPUT"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Check existing docker image
id: check-docker-image
run: |
echo "image_exists=$(docker manifest inspect ${{ steps.prep.outputs.docker_tag }} > /dev/null && echo "true" || echo "false")" >> "$GITHUB_OUTPUT"
- name: Display variables
run: |
echo git_ref: ${{ github.event.inputs.overrides_branch }}
echo sha: ${{ steps.get-sha.outputs.sha }}
echo sha4: ${{ steps.get-sha.outputs.sha4 }}
echo image_tag: ${{ steps.prep.outputs.docker_tag }}
echo image_exists: ${{ steps.check-docker-image.outputs.image_exists }}
- name: Retrieve moonbeam client
run: |
mkdir build
CLIENT_TAG=${{ github.event.inputs.client_tag }}
CLIENT_IMAGE="moonbeamfoundation/moonbeam:$CLIENT_TAG"
docker create -ti --name dummy $CLIENT_IMAGE bash
docker cp dummy:/moonbeam/moonbeam build/moonbeam
docker rm -f dummy
- name: Add moonbase runtimes overrides
run: |
mkdir -p build/moonbase-substitutes-tracing
cp wasm/moonbase-* build/moonbase-substitutes-tracing/
- name: Add moonriver runtimes overrides
run: |
mkdir -p build/moonriver-substitutes-tracing
cp wasm/moonriver-* build/moonriver-substitutes-tracing/
- name: Add moonbeam runtimes overrides
run: |
mkdir -p build/moonbeam-substitutes-tracing
cp wasm/moonbeam-* build/moonbeam-substitutes-tracing/
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: latest
driver-opts: |
image=moby/buildkit:master
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.MBF_DOCKERHUB_USERNAME }}
password: ${{ secrets.MBF_DOCKERHUB_TOKEN }}
- name: Build and push moonbeam-tracing
id: docker_build
if: ${{ steps.check-docker-image.outputs.image_exists }} == false
uses: docker/build-push-action@v5
with:
context: .
file: ./docker/moonbeam-tracing.Dockerfile
platforms: linux/amd64
push: true
tags: |
${{ steps.prep.outputs.docker_tag }}
${{ steps.prep.outputs.docker_latest_tag }}
labels: |
org.opencontainers.image.title="Moonbeam Tracing"
org.opencontainers.image.description=${{ github.event.repository.description }}
org.opencontainers.image.url=${{ github.event.repository.html_url }}
org.opencontainers.image.source=${{ github.event.repository.clone_url }}
org.opencontainers.image.created=${{ steps.prep.outputs.created }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }}