Skip to content

Commit

Permalink
Build Docker container using GH Workflows (#266)
Browse files Browse the repository at this point in the history
* Build Docker package using Github Actions
  • Loading branch information
sei-eschwartz committed Apr 9, 2024
1 parent 2089ae0 commit df0e1ab
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Docker Build and Push

on:
push:
branches:
- '*'
pull_request:
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 != 'schedule' }}
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 }}"

0 comments on commit df0e1ab

Please sign in to comment.