Skip to content

Validate Docker tags before build #4

Validate Docker tags before build

Validate Docker tags before build #4

Workflow file for this run

name: Docker Image build
on:
push:
branches: [ "main" ]
jobs:
docker:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_SECRET }}
- name: Prepare image metadata
id: prep
run: |
if [ -z "$DOCKER_USER" ]; then
echo "::error::Secret DOCKER_HUB_USERNAME is not set." >&2
exit 1
fi
if [ -z "$IMAGE_REPO" ]; then
echo "::error::Variable REPO is not set." >&2
exit 1
fi
if [ -z "$IMAGE_VERSION" ]; then
echo "::error::Variable VERSION is not set." >&2
exit 1
fi
IMAGE_NAME="$DOCKER_USER/$IMAGE_REPO"
echo "image=$IMAGE_NAME" >> "$GITHUB_OUTPUT"
echo "version=$IMAGE_VERSION" >> "$GITHUB_OUTPUT"
env:
DOCKER_USER: ${{ secrets.DOCKER_HUB_USERNAME }}
IMAGE_REPO: ${{ vars.REPO }}
IMAGE_VERSION: ${{ vars.VERSION }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.prep.outputs.image }}:latest, ${{ steps.prep.outputs.image }}:${{ steps.prep.outputs.version }}-BUILD${{ github.run_number }}