Create and publish a Docker image for sub-directory #89
Workflow file for this run
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 workflow uses actions that are not certified by GitHub. | |
# They are provided by a third-party and are governed by | |
# separate terms of service, privacy policy, and support | |
# documentation. | |
name: Create and publish a Docker image for sub-directory | |
on: | |
workflow_dispatch: | |
inputs: | |
release_tag: | |
description: "Name of release tag" | |
default: "latest" | |
type: string | |
image_name: | |
description: "Subdirectory of package" | |
default: "fenics" | |
type: string | |
image_description: | |
description: "Description of package" | |
default: "Some description" | |
type: string | |
pull_request: | |
branches: | |
- main | |
env: | |
REGISTRY: ghcr.io | |
IMAGE_NAME: fenics | |
jobs: | |
build-and-push-image: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to the Container registry | |
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: | |
labels: | | |
org.opencontainers.image.title=${{ github.event.inputs.image_name || env.IMAGE_NAME }} | |
org.opencontainers.image.description=${{ github.event.inputs.image_description }} | |
images: ${{ github.GITHUB_REPOSITORY }}/${{ github.event.inputs.image_name || env.IMAGE_NAME }} | |
tags: | | |
type=raw,value=${{ github.event.inputs.release_tag }} | |
- name: Build AMD docker image | |
uses: docker/build-push-action@v5 | |
with: | |
context: "{{defaultContext}}:fenics" | |
push: false | |
load: true | |
platforms: linux/amd64 | |
tags: ${{ steps.meta-testing.outputs.tags }} | |
labels: ${{ steps.meta-testing.outputs.labels }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.inputs.image_name || env.IMAGE_NAME }}:${{ github.event.inputs.release_tag }} | |
cache-to: type=inline | |
- name: Trigger circleci build for ARM | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: | | |
CIRCLE_RESP=$(curl \ | |
--request POST \ | |
--url https://circleci.com/api/v2/project/github/scientificcomputing/packages/pipeline \ | |
-u "${{ secrets.CIRCLECI_TOKEN }}:" \ | |
--header "Content-Type: application/json" \ | |
--data '{ "parameters": ${{ toJSON(github.event.inputs) }}, "branch": "${{ github.ref_name }}" }' | |
) | |
echo $CIRCLE_RESP | |
echo "[CircleCI Job](https://app.circleci.com/pipelines/github/scientificcomputing/packages/$(echo $CIRCLE_RESP | jq -r .number))" >> "$GITHUB_STEP_SUMMARY" | |
- name: Build and push Docker image | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
uses: docker/build-push-action@v5 | |
with: | |
context: "{{defaultContext}}:${{ github.event.inputs.image_name }}" | |
push: true | |
platforms: linux/amd64 #,linux/arm64 | |
tags: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.inputs.image_name }}:${{ github.event.inputs.release_tag }} | |
labels: ${{ steps.meta.outputs.labels }} | |
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ github.event.inputs.image_name }}:${{ github.event.inputs.release_tag }} | |
cache-to: type=inline |