-
Notifications
You must be signed in to change notification settings - Fork 2
120 lines (116 loc) · 4.87 KB
/
publish-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
110
111
112
113
114
115
116
117
118
119
120
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 }}