-
Notifications
You must be signed in to change notification settings - Fork 6
57 lines (53 loc) · 2.1 KB
/
release-kpi-tracker.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
name: Publish a docker image for KPI-tracker to DockerHub.
on:
push:
tags:
- kpi-tracker/*.*.*
workflow_dispatch:
env:
REGISTRY: docker.io
SERVICE_NAME: kpi-tracker
RUST_VERSION: rust:1.76-bookworm
jobs:
publish-docker-image:
runs-on: ubuntu-latest
environment: testnet-deployments
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
# Uses the `docker/login-action` action to log in to the Container registry.
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Extract version tag from Cargo.toml manifest.
id: meta
run: |
export VERSION=$(yq .package.version ${{ env.SERVICE_NAME }}/Cargo.toml)
export FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/${{ env.SERVICE_NAME }}:$VERSION"
echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}"
# Make sure the image does not exist. Abort if we can retrieve any metadata.
if docker manifest inspect ${FULL_IMAGE_TAG} > /dev/null; then
echo "::error ${FULL_IMAGE_TAG} already exists"
exit 1
elif [ ! "${{ github.ref_name }}" = "${{ env.SERVICE_NAME }}/${VERSION}" ]; then
echo "::error Expected tag ${EXPECTED_TAG} does not match the version ${VERSION}."
exit 1
else
# Store the full image tag into a tag variable for the following step.
echo "tag=${FULL_IMAGE_TAG}" > "$GITHUB_OUTPUT"
fi
- name: Build and push Docker image
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
with:
context: .
file: ./${{ env.SERVICE_NAME }}/scripts/Dockerfile
push: true
platforms: linux/amd64
tags: ${{ steps.meta.outputs.tag }}
build-args: |
build_image=${{ env.RUST_VERSION }}