Skip to content

Add GitHub Actions workflow for building and pushing Docker images #1

Add GitHub Actions workflow for building and pushing Docker images

Add GitHub Actions workflow for building and pushing Docker images #1

# NOTE - https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows
name: Build & Push Docker Image
on:
workflow_call:
# inputs:
# config-path:
# required: true
# type: string
secrets:
GITHUB_TOKEN:

Check failure on line 11 in .github/workflows/docker-build-and-push.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/docker-build-and-push.yml

Invalid workflow file

secret name `GITHUB_TOKEN` within `workflow_call` can not be used since it would collide with system reserved name
required: true
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v4.2.2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3.11.1
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3.4.0
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5.7.0
with:
images: ghcr.io/${{ github.repository }}
- name: Build and push Docker image
uses: docker/build-push-action@v6.18.0
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}