build-docker-image #488
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: build-docker-image | |
on: | |
push: | |
branches: | |
- master | |
repository_dispatch: | |
types: [dispatch-build] | |
workflow_dispatch: | |
jobs: | |
make-date-tag: | |
runs-on: ubuntu-latest | |
outputs: | |
dtag: ${{ steps.mkdatetag.outputs.dtag }} | |
steps: | |
- name: make date tag | |
id: mkdatetag | |
run: echo "dtag=$(date +%Y%m%d-%H%M)" >> $GITHUB_OUTPUT | |
build: | |
runs-on: ubuntu-latest | |
if: startsWith(github.repository, 'opensciencegrid/') || startsWith(github.repository, 'osg-htc/') | |
strategy: | |
fail-fast: False | |
matrix: | |
base: | |
- image: 'docker.io/library/almalinux:8' | |
tag_str: 'el8' | |
- image: 'quay.io/almalinux/almalinux:9' | |
tag_str: 'el9' | |
- image: 'nvidia/cuda:11.8.0-runtime-rockylinux8' | |
tag_str: 'cuda_11_8_0' | |
repo: ['development', 'testing', 'release'] | |
series: ['23', '24'] | |
needs: make-date-tag | |
steps: | |
- name: checkout docker-software-base | |
uses: actions/checkout@v3 | |
- id: generate-tag-list | |
env: | |
BASE_STR: ${{ matrix.base.tag_str }} | |
REPO: ${{ matrix.repo }} | |
SERIES: ${{ matrix.series }} | |
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }} | |
run: | | |
image_name=${GITHUB_REPOSITORY/opensciencegrid\/docker-/} | |
tags=() | |
for registry in hub.opensciencegrid.org docker.io; do | |
for docker_repo in opensciencegrid osg-htc; do | |
# Don't try to push to docker.io/osg-htc | |
[[ $docker_repo == "osg-htc" && $registry == "docker.io" ]] && continue | |
tags+=( $registry/$docker_repo/$image_name:$SERIES-$BASE_STR-$REPO{,-$TIMESTAMP} ) | |
done | |
done | |
# This causes the tag_list array to be comma-separated below, | |
# which is required for build-push-action | |
tag_list=$(IFS=,; echo "${tags[*]}") | |
echo "taglist=${tag_list}" >> $GITHUB_OUTPUT | |
- name: Set up Docker Buildx | |
uses: docker/[email protected] | |
- name: Log in to Docker Hub | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to OSG Harbor | |
uses: docker/[email protected] | |
with: | |
registry: hub.opensciencegrid.org | |
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }} | |
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }} | |
- name: Build and push Docker images | |
uses: docker/build-push-action@v4 | |
continue-on-error: ${{ matrix.repo == 'development' && (matrix.series == '24')}} | |
with: | |
context: . | |
push: true | |
platforms: 'linux/amd64,linux/arm64' | |
build-args: | | |
IMAGE_BASE=${{ matrix.base.image }} | |
BASE_YUM_REPO=${{ matrix.repo }} | |
OSG_RELEASE=${{ matrix.series }} | |
tags: "${{ steps.generate-tag-list.outputs.taglist }}" | |
dispatch: | |
runs-on: ubuntu-latest | |
if: startsWith(github.repository, 'opensciencegrid/') || startsWith(github.repository, 'osg-htc/') | |
needs: build | |
strategy: | |
matrix: | |
dispatch-repo: | |
- docker-compute-entrypoint | |
- docker-xcache | |
- gratia-probe | |
- htcondor-autoscale-manager | |
- open-science-pool-registry | |
- osg-repo-scripts | |
- osgvo-docker-pilot | |
- images | |
steps: | |
- name: dispatch build ${{ matrix.dispatch-repo }} | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
token: ${{ secrets.REPO_ACCESS_TOKEN }} | |
repository: opensciencegrid/${{ matrix.dispatch-repo }} | |
event-type: dispatch-build |