rebuild-dependencies #354
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
name: Docker-Publish | |
on: | |
push: | |
# Publish `main` as Docker `latest` image. | |
branches: | |
- main | |
# Publish `v1.2.3` tags as releases. | |
tags: | |
- v* | |
# Allow this event to be triggered in the github ui | |
workflow_dispatch: | |
# Allow to be triggered from an api | |
repository_dispatch: | |
types: [rebuild-dependencies] | |
env: | |
IMAGE_NAME: ablate-dependencies | |
PETSC_IMAGE_NAME: ghcr.io/ubchrest/petsc-docker/petsc-build | |
jobs: | |
get-timestamp: | |
runs-on: ubuntu-latest | |
steps: | |
- id: timestamp | |
run: | | |
# Generate a unique time stamp | |
export TIMESTAMP=$(date +%Y%m%d%H%M%S) | |
echo "time_stamp=${TIMESTAMP}" >>$GITHUB_OUTPUT | |
outputs: | |
time_stamp: ${{ steps.timestamp.outputs.time_stamp }} | |
build: | |
needs: [ get-timestamp ] | |
strategy: | |
matrix: | |
arch: [ { runson: ARM64, id: -arm64 }, { runson: ubuntu-latest, id: -amd64 } ] | |
compiler: [ { id: -gcc }, { id: -clang } ] | |
indices: [ { index64bit: 0, id: "" }, { index64bit: 1, id: "-index64" } ] | |
include: | |
# only run the fsanitize on amd to save ub resources | |
- arch: { runson: ubuntu-latest, id: -amd64 } | |
compiler: { id: -gcc-asan } | |
indices: { index64bit: 0, id: "" } | |
- arch: { runson: ubuntu-latest, id: -amd64 } | |
compiler: { id: -gcc-asan } | |
indices: { index64bit: 1, id: "-index64" } | |
runs-on: ${{ matrix.arch.runson }} | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: checkout code | |
uses: actions/checkout@v3 | |
- name: Log into registry | |
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin | |
- name: Build image | |
run: | | |
# define the image id and petsc image id | |
PETSC_IMAGE_ID=$PETSC_IMAGE_NAME${{matrix.compiler.id}}${{matrix.indices.id}}:latest | |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME${{matrix.compiler.id}}${{matrix.indices.id}}${{matrix.arch.id}} | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
echo IMAGE_ID=$IMAGE_ID | |
echo PETSC_IMAGE_ID=$PETSC_IMAGE_ID | |
# Build the image | |
docker buildx build .\ | |
--provenance false \ | |
--build-arg PETSC_BASE_IMAGE=${PETSC_IMAGE_ID} \ | |
--push \ | |
--tag $IMAGE_ID:${{ needs.get-timestamp.outputs.time_stamp}} \ | |
--file DockerDependencyFile | |
# Push the latest tag if everything build, Note this must run on max-parallel=1 | |
push-latest-tag: | |
needs: [get-timestamp, build] | |
runs-on: ubuntu-latest | |
strategy: | |
max-parallel: 1 | |
matrix: | |
arch: [ { runson: ARM64, id: -arm64 }, { runson: ubuntu-latest, id: -amd64 } ] | |
compiler: [ { id: -gcc }, { id: -clang } ] | |
indices: [ { index64bit: 0, id: "" }, { index64bit: 1, id: "-index64" } ] | |
include: | |
# only run the fsanitize on amd to save ub resources | |
- arch: { runson: ubuntu-latest, id: -amd64 } | |
compiler: { id: -gcc-asan } | |
indices: { index64bit: 0, id: "" } | |
- arch: { runson: ubuntu-latest, id: -amd64 } | |
compiler: { id: -gcc-asan } | |
indices: { index64bit: 1, id: "-index64" } | |
steps: | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- uses: actions/checkout@v3 | |
- name: Log into registry | |
run: echo "${{ secrets.CR_PAT }}" | docker login ghcr.io -u ${{ secrets.DOCKER_USER }} --password-stdin | |
- name: Build Manifest | |
run: | | |
# Define the base image id | |
IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME${{matrix.compiler.id}}${{ matrix.indices.id}} | |
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') | |
# check if image exists | |
if docker manifest inspect $IMAGE_ID:${{ needs.get-timestamp.outputs.time_stamp}} > /dev/null; then | |
echo "Appending manifest" | |
docker buildx imagetools create -t $IMAGE_ID:${{ needs.get-timestamp.outputs.time_stamp}} --append $IMAGE_ID${{matrix.arch.id}}:${{ needs.get-timestamp.outputs.time_stamp}} | |
docker buildx imagetools create -t $IMAGE_ID:latest --append $IMAGE_ID${{matrix.arch.id}}:${{ needs.get-timestamp.outputs.time_stamp}} | |
else | |
echo "Creating new manifest" | |
docker buildx imagetools create -t $IMAGE_ID:${{ needs.get-timestamp.outputs.time_stamp}} $IMAGE_ID${{matrix.arch.id}}:${{ needs.get-timestamp.outputs.time_stamp}} | |
docker buildx imagetools create -t $IMAGE_ID:latest $IMAGE_ID${{matrix.arch.id}}:${{ needs.get-timestamp.outputs.time_stamp}} | |
fi |