Skip to content

Commit

Permalink
WIP: reusable container workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
tamcore committed Dec 24, 2022
1 parent 74816a4 commit f3841cc
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 49 deletions.
61 changes: 12 additions & 49 deletions .github/workflows/docker-weekly.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
name: weekly docker build

on:
schedule:
- cron: '0 0 * * 1' # Monday midnight
# Monday midnight
- cron: '0 0 * * 1'
workflow_dispatch:

permissions:
Expand All @@ -11,51 +13,12 @@ permissions:

jobs:
weekly-container-build:
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: arm64,amd64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Docker meta
id: metadata
uses: docker/metadata-action@v3
with:
images: |
ghcr.io/${{ github.repository }}
tags: |
type=raw,value=alpha
type=raw,value=alpha-{{date 'YYYYMMDD'}}
type=raw,value=alpha-{{sha}}
- name: Build release image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
QEMU_CPU=max,pauth-impdef=on
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
file: tools/docker/Dockerfile.ubuntu-build
cache-from: type=gha
cache-to: type=gha,mode=max
uses: ./.github/workflows/reusable-container-workflow.yaml
with:
dockerfile: tools/docker/Dockerfile.ubuntu-build
tag: alpha
image: ghcr.io/${{ github.repository }}
registry: ghcr.io
registry_username: ${{ github.repository_owner }}
secrets:
registry_password: ${{ secrets.GITHUB_TOKEN }}
72 changes: 72 additions & 0 deletions .github/workflows/reusable-container-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Reusable Container Build Workflow

on:
workflow_call:
inputs:
dockerfile:
required: true
type: string
tag:
required: true
type: string
image:
required: true
type: string
registry:
required: true
type: string
registry_username:
required: true
type: string
secrets:
registry_password:
required: true

jobs:
container-build:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
submodules: true

- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
platforms: arm64,amd64

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ${{ inputs.registry }}
username: ${{ inputs.registry_username }}
password: ${{ inputs.registry_password }}

- name: Docker meta
id: metadata
uses: docker/metadata-action@v3
with:
images: |
${{ inputs.image }}
tags: |
type=raw,value=${{ inputs.tag }}
type=raw,value=${{ inputs.tag }}-{{date 'YYYYMMDD'}}
- name: Build release image
uses: docker/build-push-action@v3
with:
context: .
platforms: linux/amd64,linux/arm64
build-args: |
QEMU_CPU=max,pauth-impdef=on
push: true
tags: ${{ steps.metadata.outputs.tags }}
labels: ${{ steps.metadata.outputs.labels }}
file: ${{ inputs.dockerfile }}
cache-from: type=gha
cache-to: type=gha,mode=max

0 comments on commit f3841cc

Please sign in to comment.