Merge pull request #24 from adfinis/chore/dependabot_docker_fix #17
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and Publish Docker Image | |
on: | |
push: | |
branches: | |
- "**" # Trigger on push to any branch | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build-and-push: | |
permissions: write-all | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Log into the Container registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.REGISTRY }} | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Extract branch name | |
id: extract_branch | |
run: echo "branch_name=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
- name: Replace slashes in branch name | |
id: sanitize_branch | |
run: | | |
sanitized_branch_name=$(echo "${{ env.branch_name }}" | tr '/' '-') | |
echo "sanitized_branch_name=$sanitized_branch_name" >> $GITHUB_ENV | |
- name: Extract metadata for the Docker image | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} | |
- name: Build and push the Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ env.sanitized_branch_name }}-nightly |