Files
gh-christianlouis-docuelevate/.github/workflows/docker-build.yaml
T
Christian Krakau-Louis 60bcf7d964 Update docker-build.yaml
2025-03-28 20:54:04 +01:00

63 lines
1.9 KiB
YAML

name: Build and Push Docker Image
permissions:
contents: read
packages: write
on:
push:
branches:
- main
- develop
tags:
- 'v*'
- '[0-9]+.*'
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract Git Tag (if applicable)
if: startsWith(github.ref, 'refs/tags/')
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build and Push Docker Image
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
context: .
file: Dockerfile
push: true
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
christianlouis/document-processor:latest
christianlouis/document-processor:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/document-processor:latest
ghcr.io/${{ github.repository_owner }}/document-processor:${{ github.sha }}
${{ startsWith(github.ref, 'refs/tags/') && format('christianlouis/document-processor:{0}', env.VERSION) || '' }}
${{ startsWith(github.ref, 'refs/tags/') && format('ghcr.io/{0}/document-processor:{1}', github.repository_owner, env.VERSION) || '' }}