Skip to content

Add OSG 24 support to new_mashfile.sh #397

Add OSG 24 support to new_mashfile.sh

Add OSG 24 support to new_mashfile.sh #397

name: Build and Push Docker image
on:
push:
branches: ['master', 'el9']
repository_dispatch:
types:
- dispatch-build
workflow_dispatch:
jobs:
make-date-tag:
runs-on: ubuntu-latest
if: startsWith(github.repository, 'osg-htc/')
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
needs: [make-date-tag]
if: startsWith(github.repository, 'osg-htc/')
strategy:
fail-fast: False
matrix:
repo: ['release']
steps:
- uses: actions/checkout@v3
- name: Generate tag list
id: generate-tag-list
env:
REPO: ${{ matrix.repo }}
TIMESTAMP: ${{ needs.make-date-tag.outputs.dtag }}
run: |
baseref=$(basename "$GITHUB_REF")
if [[ $baseref == master ]]; then
docker_repo=opensciencegrid/osg-repo-scripts
registries=(hub.opensciencegrid.org docker.io)
tag_prefix=$REPO
elif [[ $baseref == el9 ]]; then
docker_repo=osg-htc/osg-repo-scripts
registries=(hub.opensciencegrid.org)
tag_prefix=el9
else
echo >&2 "No image name rule for ref '$GITHUB_REF'"
exit 1
fi
tag_list=()
for registry in ${registries[*]}; do
for image_tag in "${tag_prefix}" "${tag_prefix}-$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]
- 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
with:
context: .
push: true
build-args: BASE_YUM_REPO=${{ matrix.repo }}
tags: "${{ steps.generate-tag-list.outputs.taglist }}"