Skip to content

Build and Push Docker Images #2

Build and Push Docker Images

Build and Push Docker Images #2

Workflow file for this run

name: Build and Push Docker Images
on:
schedule:
- cron: '0 0 1 * *' # Run monthly on the 1st
workflow_dispatch: # Allow manual triggers
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
strategy:
matrix:
variant:
- name: regular
file: Dockerfile
suffix: ''
- name: alpine
file: Dockerfile-alpine
suffix: '-alpine'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest${{ matrix.variant.suffix }}
type=raw,value={{date 'YYYYMMDD'}}${{ matrix.variant.suffix }}
- name: Build and push image
uses: docker/build-push-action@v5
with:
context: .
file: ./${{ matrix.variant.file }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}