Skip to content

Merge pull request #328 from Concordium/feature/COR-2315-precision-nu… #16

Merge pull request #328 from Concordium/feature/COR-2315-precision-nu…

Merge pull request #328 from Concordium/feature/COR-2315-precision-nu… #16

name: Publish Docker image for credential-verification-service to DockerHub
on:
workflow_dispatch: # allows manual trigger
push:
tags:
- 'credential-verification-service/*.*.*'
env:
REGISTRY: docker.io
IMAGE_NAME: credential-verification-service
RUST_VERSION: rust:1.91-slim # Define the Rust version here
SERVICE_NAME: credential-verification-service
jobs:
release-docker:
runs-on: ubuntu-latest
environment: release-unprivileged
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Extract version tag from Cargo.toml manifest
id: meta
run: |
VERSION=$(yq .package.version $SERVICE_NAME/Cargo.toml)
FULL_IMAGE_TAG="${{ env.REGISTRY }}/concordium/${{ env.IMAGE_NAME }}:$VERSION"
echo "::notice FULL_IMAGE_TAG=${FULL_IMAGE_TAG}"
SERVICE_NAME=${{ env.SERVICE_NAME }}
# 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 }}" = "$SERVICE_NAME/$VERSION" ]; then
echo "::error ${{ github.ref_name }} does not match $SERVICE_NAME/$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@v5
with:
context: .
file: credential-verification-service/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tag }}
build-args: |
build_image=${{ env.RUST_VERSION }}