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@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 with: registry: ${{ env.REGISTRY }} username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - name: Extract metadata for Docker id: meta uses: docker/metadata-action@369eb591f429131d6889c46b94e711f089e6ca96 # 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 }}