Skip to content

Build GitHub Actions custom docker images #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions .github/actions/build-gha-docker-image/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions
# https://docs.github.com/en/actions/use-cases-and-examples/publishing-packages/publishing-docker-images#publishing-images-to-github-packages
name: 'Build docker image for use in GitHub Actions'
description: 'Builds a docker image for use in GitHub Actions for a given compiler and a given compiler version.'

inputs:
compiler-name:
description: 'The Fortran compiler to install.'
required: true
compiler-version:
description: 'The compiler version to install.'
required: true
docker-registry-name:
description: 'The docker registry to publish to.'
default: 'ghcr.io'
docker-registry-username:
description: 'The username to login to the docker registry with.'
required: true
docker-registry-password:
description: 'The password to login to the docker registry with.'
required: true
image-name:
description: 'The name of the docker image.'
required: true

runs:
using: 'composite'
steps:
- name: "Log in to the container registry"
uses: docker/login-action@v3
with:
registry: ${{ inputs.docker-registry-name }}
username: ${{ inputs.docker-registry-username }}
password: ${{ inputs.docker-registry-password }}

- name: 'Construct long-form docker tag'
id: long-form-tag
shell: bash
run: |
echo "tag=type=raw,value=linux-${{ inputs.compiler-name }}-${{ inputs.compiler-version }}-pr-${{ github.event.number }}" >> "${GITHUB_OUTPUT}"

- name: "Extract metadata (tags, labels) for docker"
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.docker-registry-name }}/${{ inputs.image-name }}
tags: |
${{ steps.long-form-tag.outputs.tag }}
type=raw,value=${{ inputs.compiler-name }}-${{ inputs.compiler-version }}
type=sha
type=ref,enable=true,priority=600,prefix=,suffix=,event=branch
type=ref,enable=true,priority=600,prefix=,suffix=,event=tag
type=ref,enable=true,priority=600,prefix=pr-,suffix=,event=pr

- name: "Build and push docker image"
id: push
uses: docker/build-push-action@v6
with:
context: docker/github-actions/
build-args: |
COMPILER=${{ inputs.compiler-name }}
VERSION=${{ inputs.compiler-version }}
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
38 changes: 38 additions & 0 deletions .github/actions/test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: 'Test setup-fortran ran correctly'
description: 'Checks the system after setup-fortran has run.'

inputs:
compiler-name:
description: 'The Fortran compiler installed.'
required: true
compiler-version:
description: 'The compiler version installed.'
required: true
output-mode:
description: 'The output mode of CI.'
required: true

runs:
using: 'composite'
steps:
- name: 'Test Fortran compiler'
uses: ./.github/actions/test-fc
with:
compiler: ${{ inputs.compiler-name }}
version: ${{ inputs.compiler-version }}

- name: 'Test C compiler'
continue-on-error: true
if: inputs.output-mode == 'report'
uses: ./.github/actions/test-cc
with:
compiler: ${{ inputs.compiler-name }}
version: ${{ inputs.compiler-version }}

- name: 'Test C++ compiler'
continue-on-error: true
if: inputs.output-mode == 'report'
uses: ./.github/actions/test-cxx
with:
compiler: ${{ inputs.compiler-name }}
version: ${{ inputs.compiler-version }}
Loading
Loading