Skip to content

Merge branch 'main' into my-customizations #13

Merge branch 'main' into my-customizations

Merge branch 'main' into my-customizations #13

name: Docker Build and Push
on:
push:
branches:
- my-customizations
workflow_dispatch:
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set repository and image name to lowercase
run: |
echo "IMAGE_NAME=${IMAGE_NAME,,}" >> ${GITHUB_ENV}
echo "FULL_IMAGE_NAME=${REGISTRY}/${IMAGE_NAME,,}" >> ${GITHUB_ENV}
env:
IMAGE_NAME: '${{ github.repository }}'
- 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 the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.MY_GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.FULL_IMAGE_NAME }}
tags: |
type=ref,event=branch
type=sha,prefix=git-
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile.local
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
BUILD_HASH=${{ github.sha }}
- name: Image digest
run: echo ${{ steps.docker_build.outputs.digest }}
- name: Debug - Display Docker build output
if: failure()
run: |
docker build -f Dockerfile.local . 2>&1 | tee build_output.log
echo "Last 1000 lines of build output:"
tail -n 1000 build_output.log
- name: Upload build log as artifact
if: failure()
uses: actions/upload-artifact@v3
with:
name: docker-build-log
path: build_output.log