Skip to content

Image Creator

Image Creator #10

Workflow file for this run

name: 'Image Creator'
on:
# A executer que lorsque l'on demande.
workflow_dispatch:
inputs:
os_base:
description: 'OS base'
required: true
default: 'ubuntu-2204'
type: choice
options:
- 'ubuntu-2204'
- 'ubuntu-2004'
compiler:
description: 'Compiler'
required: true
default: 'gcc-12'
type: choice
options:
- 'gcc-12'
- 'gcc-11'
- 'clang-15'
- 'clang-14'
- 'clang-13'
- 'cuda-120'
- 'cuda-118'
- 'cuda-117'
- 'cuda-116'
dependencies:
description: 'Dependencies'
required: true
default: 'full'
type: choice
options:
- 'full'
- 'minimal'
- 'doc'
build_type:
description: 'Build type'
required: true
default: 'release'
type: choice
options:
- 'release'
- 'debug'
- 'check'
dockerfile_only:
description: 'Generate only the Dockerfile (upload as artifact)'
required: true
type: boolean
env:
REGISTRY: 'ghcr.io'
USER_NAME: 'arcaneframework'
DOCKERFILE_IN: './.github/scripts/Dockerfile.in'
DOCKERFILE_OUT: './Dockerfile'
jobs:
build-and-push:
name: Build and Push
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Generate Dockerfile
shell: 'bash'
run: |
./.github/scripts/DockerfileGenerator.sh \
--os ${{ inputs.os_base }} \
--compiler ${{ inputs.compiler }} \
--image_version ${{ inputs.dependencies }} \
--build_type ${{ inputs.build_type }} \
--dockerfile_in ${{ env.DOCKERFILE_IN }} \
--dockerfile_out ${{ env.DOCKERFILE_OUT }}
- name: Log in to the Container registry
uses: docker/login-action@v2
if: ${{ ! inputs.dockerfile_only }}
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
if: ${{ ! inputs.dockerfile_only }}
with:
images: ${{ env.REGISTRY }}/${{ env.USER_NAME }}/arcane_${{ inputs.os_base }}
labels: |
org.opencontainers.image.title=ArcaneFramework
org.opencontainers.image.description=Arcane Framework Image
org.opencontainers.image.vendor=CEA
tags: |
type=raw, ${{ inputs.compiler }}_${{ inputs.dependencies }}_${{ inputs.build_type }}_latest
type=raw, ${{ inputs.compiler }}_${{ inputs.dependencies }}_${{ inputs.build_type }}_{{date 'YYYYMMDD'}}
- name: Build and push Docker image
uses: docker/build-push-action@v3
if: ${{ ! inputs.dockerfile_only }}
with:
context: .
file: ${{ env.DOCKERFILE_OUT }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Display error
if: ${{ failure() }}
run: echo "::error::Base image unknown, see available images here https://github.com/arcaneframework/framework-ci#images-disponibles"
- name: Upload Dockerfile generated
uses: actions/upload-artifact@v3
with:
name: arcane_${{ inputs.os_base }}_${{ inputs.compiler }}_${{ inputs.dependencies }}_${{ inputs.build_type }}_dockerfile
path: ${{ env.DOCKERFILE_OUT }}
retention-days: 7