Skip to content

4C docker image

4C docker image #577

name: 4C docker image
on:
workflow_run:
workflows: [nightly_tests]
types: [completed]
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
REGISTRY: ghcr.io
IMAGE_NAME: ghcr.io/4c-multiphysics/4c
jobs:
build_4c_image:
runs-on: ubuntu-latest
if: ${{ github.repository == '4C-multiphysics/4C' }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Log in to the Container registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.IMAGE_NAME }}
labels: |
org.opencontainers.image.description=Image containing the built 4C code
- name: Create tags
id: tags
# If the nightly tests are successful the docker image is additionally tagged as `stable`
run: |
TAGS="${{ env.IMAGE_NAME }}:main"
if [[ "${{ github.event.workflow_run.conclusion }}" == 'success' ]]; then
TAGS="$TAGS,${{ env.IMAGE_NAME }}:stable"
fi
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
id: push
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: .
file: docker/prebuilt_4C/Dockerfile
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build_4c_minimal_image:
runs-on: ubuntu-latest
if: ${{ github.repository == '4C-multiphysics/4C' }}
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Checkout repository
uses: actions/checkout@v6
- name: Log in to the Container registry
uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@c299e40c65443455700f0fdfc63efafe5b349051 # v5.10.0
with:
images: ${{ env.IMAGE_NAME }}-minimal
labels: |
org.opencontainers.image.description=Image containing the 4C executable
- name: Create tags
id: tags
# If the nightly tests are successful the docker image is additionally tagged as `stable`
run: |
TAGS="${{ env.IMAGE_NAME }}-minimal:main"
if [[ "${{ github.event.workflow_run.conclusion }}" == 'success' ]]; then
TAGS="$TAGS,${{ env.IMAGE_NAME }}-minimal:stable"
fi
echo "tags=$TAGS" >> "$GITHUB_OUTPUT"
- name: Build and push Docker image
id: push
uses: docker/build-push-action@10e90e3645eae34f1e60eeb005ba3a3d33f178e8 # v6.19.2
with:
context: docker/prebuilt_4C_minimal
file: docker/prebuilt_4C_minimal/Dockerfile
push: true
tags: ${{ steps.tags.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}