Skip to content

dispatch-build

dispatch-build #487

name: Build release series tagged container images
on:
push:
branches:
- master
pull_request:
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
image-builds:
runs-on: ubuntu-latest
needs: [make-date-tag]
strategy:
fail-fast: False
matrix:
repo: ['development', 'testing', 'release']
image: ['hosted-ce', 'osg-ce-condor']
osg_series:
- name: '23'
os: 'el9'
steps:
- uses: actions/checkout@v3
- name: Log in to Docker Hub
uses: docker/[email protected]
if: github.event_name != 'pull_request' && startsWith(github.repository, 'opensciencegrid/')
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to OSG Harbor
uses: docker/[email protected]
if: github.event_name != 'pull_request' && startsWith(github.repository, 'opensciencegrid/')
with:
registry: hub.opensciencegrid.org
username: ${{ secrets.OSG_HARBOR_ROBOT_USER }}
password: ${{ secrets.OSG_HARBOR_ROBOT_PASSWORD }}
- name: Build Base Docker image
uses: docker/build-push-action@v4
with:
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series.name }}
BASE_OS=${{ matrix.osg_series.os }}
context: ./base
pull: True
load: True
tags: base:latest
- name: Generate tag list
id: generate-tag-list
env:
REPO: ${{ matrix.repo }}
IMAGE: ${{ matrix.image }}
OSG_SERIES: ${{ matrix.osg_series.name }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
docker_repo=opensciencegrid/$IMAGE
tag_list=()
for registry in hub.opensciencegrid.org docker.io; do
for image_tag in "$OSG_SERIES-$REPO" "$OSG_SERIES-$REPO-$TIMESTAMP"; do
tag_list+=("$registry/$docker_repo":"$image_tag")
done
done
# This causes the tag_list array to be comma-separated below,
# which is required for build-push-action
IFS=,
echo "taglist=${tag_list[*]}" >> $GITHUB_OUTPUT
- name: Set up Docker Buildx
uses: docker/[email protected]
with:
driver: docker # If not set to docker driver, it will default to docker-container
# when using load for the build-push-action.
- name: Build and push hosted-ce and osg-ce-condor images
uses: docker/build-push-action@v4
with:
push: ${{ github.event_name != 'pull_request' && startsWith(github.repository, 'opensciencegrid/') }}
context: ${{matrix.image}}
build-args: |
BASE_YUM_REPO=${{ matrix.repo }}
BASE_OSG_SERIES=${{ matrix.osg_series }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"