Create action for building docker images (#41)

This commit is contained in:
Arjan H
2023-04-16 12:39:05 +02:00
parent 0ed9d8eac2
commit 61d3ddb4dc
5 changed files with 129 additions and 18 deletions

109
.github/workflows/build-dockers.yml vendored Normal file
View File

@@ -0,0 +1,109 @@
name: Build Docker Images
on:
push:
branches:
- "**"
tags:
- "v*"
pull_request:
branches:
- "main"
workflow_dispatch:
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Build binaries
run: |
build/build.sh
- name: Import GPG key
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: Commit any updated files
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "[skip ci] Commit changes from build-dockers action"
commit_options: "-S"
commit_user_email: ${{ vars.COMMIT_USER }}
- name: Cache build output
uses: actions/cache/save@v3
with:
path: build
key: build-dockers
build-publish:
runs-on: ubuntu-latest
needs: prepare
strategy:
matrix:
include:
- image: ghcr.io/hakwerk/labca-gui
dockerfile: build/Dockerfile-gui
label: org.opencontainers.image.title=labca-gui
- image: ghcr.io/hakwerk/labca-boulder
dockerfile: build/Dockerfile-boulder
label: org.opencontainers.image.title=labca-boulder
- image: ghcr.io/hakwerk/labca-control
dockerfile: build/Dockerfile-control
label: org.opencontainers.image.title=labca-control
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Restore build output
uses: actions/cache/restore@v3
with:
path: build
key: build-dockers
- name: Set up docker buildx
uses: docker/setup-buildx-action@v2
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ${{ matrix.image }}
labels: ${{ matrix.label }}
tags: |
type=schedule,pattern={{date 'YYYYMMDD'}}
type=match,pattern=v(.*),group=1
type=edge,branch=$repo.default_branch
type=ref,event=branch
type=ref,event=pr
type=sha
- name: Login to GHCR
if: github.event_name != 'pull_request'
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.ACTION_PAT }}
- name: Build and push
uses: docker/build-push-action@v4
with:
context: build
file: ${{ matrix.dockerfile }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}

View File

@@ -36,5 +36,6 @@ jobs:
- name: Apply our config patches
run: |
cd boulder
cp -r test labca
../patch-cfg.sh