forked from cmu-sei/pharos
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build Docker container using GH Workflows (cmu-sei#266)
* Build Docker package using Github Actions
- Loading branch information
1 parent
2089ae0
commit df0e1ab
Showing
1 changed file
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }}" |