| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- 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@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
- with:
- persist-credentials: false
- - name: Log in to the Container registry
- uses: docker/login-action@74a5d142397b4f367a81961eba4e8cd7edddf772 # v3
- with:
- registry: ${{ env.REGISTRY }}
- username: ${{ github.actor }}
- password: ${{ secrets.GITHUB_TOKEN }}
- - name: Extract metadata for Docker
- id: meta
- uses: docker/metadata-action@902fa8ec7d6ecbf8d84d538b9b233a880e428804 # 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@ca052bb54ab0790a636c9b5f226502c73d547a25 # v5
- with:
- context: .
- file: ./${{ matrix.variant.file }}
- push: true
- tags: ${{ steps.meta.outputs.tags }}
- labels: ${{ steps.meta.outputs.labels }}
|