Skip to content

Second try

Second try #40

Workflow file for this run

name: Docker Build and Push
on:
push:
branches:
- '*'
pull_request:
# Enabling this has some security implications. For now we'll leave it off.
#pull_request_target:
# types: [labeled]
schedule:
- cron: '42 06 * * sat' # Run every Saturday at 06:42 UTC
env:
REGISTRY: ghcr.io
jobs:
build-and-push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry (GHCR)
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ github.repository }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: .
push: ${{ github.event_name == 'push' || ( github.event_name == 'pull_request_target' && contains(github.event.pull_request.labels.*.name, 'push to docker'))}}
build-args: |
CFLAGS=
NCPU=4
provenance: false
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
# Don't use cache for weekly builds
cache-from: ${{ (github.event_name != 'schedule') && 'type=gha' }}
cache-to: type=gha,mode=max
- name: Log Docker image digest
if: steps.build-and-push.outputs.pushed
run: echo "Docker image pushed ${{ steps.build-and-push.outputs.digest }}"