Some checks failed
Build and publish Docker image / build-and-push (push) Failing after 3m46s
Signed-off-by: Stephen Simpson <ssimpson89@users.noreply.github.com>
78 lines
2.2 KiB
YAML
78 lines
2.2 KiB
YAML
name: Build and publish Docker image
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- dev
|
|
- master
|
|
tags:
|
|
- '*.*.*'
|
|
workflow_dispatch:
|
|
|
|
env:
|
|
IMAGE_NAME: rocky-dev
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
steps:
|
|
- name: Get Registry
|
|
id: registry
|
|
run: |
|
|
# Use RUNNER_REGISTRY environment variable
|
|
if [ ! -z "${RUNNER_REGISTRY}" ]; then
|
|
REGISTRY="${RUNNER_REGISTRY}"
|
|
else
|
|
echo "ERROR: RUNNER_REGISTRY environment variable not set"
|
|
echo "Please add RUNNER_REGISTRY to your runner's environment variables"
|
|
exit 1
|
|
fi
|
|
|
|
echo "registry=${REGISTRY}" >> $GITHUB_OUTPUT
|
|
echo "Using registry: ${REGISTRY}"
|
|
|
|
- name: Checkout code
|
|
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: Log in to registry
|
|
uses: docker/login-action@v3
|
|
with:
|
|
registry: ${{ steps.registry.outputs.registry }}
|
|
username: ${{ vars.USERNAME }}
|
|
password: ${{ secrets.PASS }}
|
|
|
|
- name: Extract Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v5
|
|
with:
|
|
images: ${{ steps.registry.outputs.registry }}/${{ vars.USERNAME }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
# Only tag with version and latest on tag push
|
|
type=semver,pattern={{version}},enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
|
|
# Optionally, tag dev/master builds with branch name (for testing)
|
|
type=ref,event=branch,enable=${{ !startsWith(github.ref, 'refs/tags/') }}
|
|
|
|
- name: Build and push Docker image
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
file: ./Dockerfile
|
|
push: true
|
|
platforms: linux/amd64,linux/arm64
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|