dispatch-build #397
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/') | |
strategy: | |
fail-fast: False | |
matrix: | |
base: | |
- image: 'docker.io/centos:centos7' | |
tag_str: 'el7' | |
- image: 'quay.io/centos/centos:stream8' | |
tag_str: 'el8' | |
- image: 'docker.io/library/almalinux:8' | |
tag_str: 'al8' | |
- 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: ['3.6', '23'] | |
# Exclude EL7 for OSG 23 builds | |
exclude: | |
# exclude/include for nested dict items have to use the dict form | |
# https://github.com/actions/runner/issues/1512 | |
- base: {image: 'docker.io/centos:centos7', tag_str: 'el7'} | |
series: '23' | |
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: | | |
docker_repo=${GITHUB_REPOSITORY/opensciencegrid\/docker-/opensciencegrid/} | |
tags=() | |
for registry in hub.opensciencegrid.org docker.io; do | |
tags+=( $registry/$docker_repo:$SERIES-$BASE_STR-$REPO{,-$TIMESTAMP} ) | |
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/setup-buildx-action@v2.7.0 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2.2.0 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Log in to OSG Harbor | |
uses: docker/login-action@v2.2.0 | |
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 == '23' }} | |
with: | |
context: . | |
push: true | |
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/') | |
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 |