-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into pbrubeck/feature/fenics-bcs
- Loading branch information
Showing
14 changed files
with
550 additions
and
107 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
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,101 @@ | ||
name: Reusable Docker workflow | ||
|
||
# This workflow creates x86 or ARM images and then pushes them by digest. These | ||
# are then combined in a separate step. See | ||
# https://docs.docker.com/build/ci/github-actions/multi-platform/ for more information. | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
os: | ||
description: 'Self-hosted machine to run on' | ||
required: true | ||
type: string | ||
platform: | ||
description: 'Target docker platform (one of linux/amd64 or linux/arm64)' | ||
required: true | ||
type: string | ||
target: | ||
description: 'Target Docker image name' | ||
required: true | ||
type: string | ||
tag: | ||
description: 'Optional tag (defaults to `latest`)' | ||
required: false | ||
default: 'latest' | ||
type: string | ||
dockerfile: | ||
description: 'Path to the Dockerfile required to build image' | ||
required: true | ||
type: string | ||
extra-install-flags: | ||
description: 'Extra args to pass when building the Dockerfile' | ||
default: '' | ||
required: false | ||
type: string | ||
secrets: | ||
# Docker login information | ||
DOCKERHUB_USER: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
docker_build: | ||
name: "Build the ${{ inputs.target }} container" | ||
strategy: | ||
fail-fast: false | ||
runs-on: [self-hosted, "${{ inputs.os }}"] | ||
steps: | ||
- name: Pre-cleanup | ||
if: always() | ||
run: | | ||
rm -rf ${{ runner.temp }}/digests | ||
- name: Add homebrew to PATH | ||
if: inputs.os == 'macOS' | ||
run: | | ||
: # https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/workflow-commands-for-github-actions#adding-a-system-path | ||
echo "/opt/homebrew/bin" >> "$GITHUB_PATH" | ||
- name: Check out the repo | ||
uses: actions/checkout@v4 | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push ${{ inputs.target }} | ||
id: build | ||
uses: docker/build-push-action@v6 | ||
with: | ||
platforms: ${{ inputs.platform }} | ||
file: ${{ inputs.dockerfile }} | ||
build-args: EXTRA_INSTALL_FLAGS=${{ inputs.extra-install-flags }} | ||
outputs: type=image,name=firedrakeproject/${{ inputs.target }},push-by-digest=true,name-canonical=true,push=true | ||
|
||
- name: Export digest | ||
run: | | ||
: # Create a file in <tempdir>/digests with name matching the pushed image hash | ||
rm -rf ${{ runner.temp }}/digests | ||
mkdir -p ${{ runner.temp }}/digests | ||
digest="${{ steps.build.outputs.imageid }}" | ||
touch "${{ runner.temp }}/digests/${digest#sha256:}" | ||
- name: Upload digest | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: digests_${{ inputs.target }}_${{ inputs.os }} | ||
path: ${{ runner.temp }}/digests/* | ||
if-no-files-found: error | ||
retention-days: 1 | ||
|
||
- name: Post-cleanup | ||
if: always() | ||
run: | | ||
rm -rf ${{ runner.temp }}/digests |
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,62 @@ | ||
name: Reusable Docker workflow | ||
|
||
# This workflow merges Linux and macOS images and pushes them to Docker. | ||
# See https://docs.docker.com/build/ci/github-actions/multi-platform/ for more information. | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
target: | ||
description: 'Target docker image name to upload to' | ||
required: true | ||
type: string | ||
tag: | ||
description: 'Optional tag (defaults to `latest`)' | ||
required: false | ||
default: 'latest' | ||
type: string | ||
secrets: | ||
# Docker login information | ||
DOCKERHUB_USER: | ||
required: true | ||
DOCKERHUB_TOKEN: | ||
required: true | ||
|
||
jobs: | ||
docker_merge: | ||
runs-on: [self-hosted, Linux] | ||
steps: | ||
- name: Pre-cleanup | ||
if: always() | ||
run: | | ||
rm -rf ${{ runner.temp }}/digests | ||
- name: Download digests | ||
uses: actions/download-artifact@v4 | ||
with: | ||
path: ${{ runner.temp }}/digests | ||
pattern: digests_${{ inputs.target }}_* | ||
merge-multiple: true | ||
|
||
- name: Log in to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USER }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Merge and push the per-platform images | ||
working-directory: ${{ runner.temp }}/digests | ||
run: | | ||
docker buildx imagetools create -t firedrakeproject/${{ inputs.target }}:${{ inputs.tag }} $(printf 'firedrakeproject/${{ inputs.target }}@sha256:%s ' *) | ||
- name: Inspect image | ||
run: | | ||
docker buildx imagetools inspect firedrakeproject/${{ inputs.target }}:${{ inputs.tag }} | ||
- name: Post-cleanup | ||
if: always() | ||
run: | | ||
rm -rf ${{ runner.temp }}/digests |
Oops, something went wrong.