Build and Push SL7 Workspaces #13
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
# SPDX-FileCopyrightText: 2020 Fermi Research Alliance, LLC | |
# SPDX-License-Identifier: Apache-2.0 | |
# This workflow can be triggered w/ a dispatch event, e.g.: | |
# curl -X POST -H "Authorization: token $(cat ../token_file)" \ | |
# -H "Content-Type: application/json" -H "Accept: application/vnd.github.v3+json" \ | |
# https://api.github.com/repos/glideinwms/containers/dispatches \ | |
# -d '{"event_type":"workspaces-sl7-build", "client_payload": {"label":"latest", "date_tag":true}}' | |
# A valid GitHub token must be saved in the file (so that is presented in the authorization) | |
# otherwise a misleading "Not Found" message is returned. No reply is provided for successful posts. | |
# The client_payload label and date_tag are optional | |
# label is used as Docker Hub label instead of "latest" | |
# if date_tag id true a date tag is added to the Docker Hub label (+%Y%m%d-%H%M) | |
# -X POST is also optional | |
# | |
# You can use also the gh cli: | |
# jq -n '{"event_type":"workspaces-sl7-build", "client_payload": {"label":"latest", "date_tag":true}}' | \ | |
# gh api repos/glideinwms/containers/dispatches --input - | |
# TODO: reduce run times, these allow filters at the job level: | |
# https://github.com/tj-actions/changed-files | |
# https://github.com/dorny/paths-filter | |
name: Build and Push SL7 Workspaces | |
on: | |
push: | |
branches: [main ] | |
paths: ['workspaces/gwms-workspace/Dockerfile.sl7'] | |
pull_request: | |
branches: [main ] | |
paths: ['workspaces/gwms-workspace/Dockerfile.sl7'] | |
workflow_dispatch: | |
inputs: | |
date_tag: | |
description: 'True to add the date to the image tag' | |
required: true | |
default: false | |
type: boolean | |
label: | |
description: 'Label to use as image tag' | |
required: false | |
type: string | |
repository_dispatch: | |
types: | |
- workspaces-sl7-build | |
env: | |
DH_LABEL: latest | |
OSG_VERSION: NO | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: set env date and hash | |
id: setenv_vars | |
shell: bash | |
run: | | |
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV | |
echo "GITHUB_HASH=$(git rev-parse --short "$GITHUB_SHA")" >> $GITHUB_ENV | |
- name: set label branch | |
id: setlabel_branch | |
shell: bash | |
run: | | |
if [[ ${GITHUB_REF##*/} = osg* ]]; then | |
echo "DH_LABEL=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
echo "OSG_VERISON=${GITHUB_REF##*/}" >> $GITHUB_ENV | |
fi | |
- name: set label from parameter | |
id: setlabel_parameter | |
continue-on-error: true | |
if: ${{ github.event.client_payload.label }} | |
run: | | |
echo "DH_LABEL=${{ github.event.client_payload.label }}" >> $GITHUB_ENV | |
- name: set label from inputs | |
id: setlabel_inputs | |
continue-on-error: true | |
if: ${{ inputs.label }} | |
run: | | |
echo "DH_LABEL=${{ inputs.label }}" >> $GITHUB_ENV | |
- name: add date tag | |
continue-on-error: true | |
if: ${{ github.event.client_payload.date_tag }} || ${{ inputs.date_tag }} | |
run: | | |
echo "DH_LABEL=$DH_LABEL-$(date +%Y%m%d-%H%M)" >> $GITHUB_ENV | |
- uses: satackey/[email protected] | |
# Ignore the failure of a step and avoid terminating the job. | |
continue-on-error: true | |
with: | |
key: gwms-docker-cache-{hash} | |
restore-keys: | | |
gwms-docker-cache- | |
# SL7 is only available for amd64 | |
#- name: Set up QEMU | |
# uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Build and push gwms-workspace SL7 | |
id: docker_build_gwms_workspace_sl7 | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
#platforms: linux/amd64 | |
context: workspaces | |
file: workspaces/gwms-workspace/Dockerfile.sl7 | |
tags: glideinwms/gwms-workspace:sl7_${{env.DH_LABEL}} | |
build-args: | | |
BUILD_SHA=${{env.GITHUB_SHA}} | |
BUILD_HASH=${{env.GITHUB_HASH}} | |
BUILD_REF=${{env.GITHUB_REF}} | |
BUILD_DATE=${{env.BUILD_DATE}} | |
GWMS_VERSION=sl7_${{env.DH_LABEL}} | |
#cache-from: type=gha | |
#cache-to: type=gha,mode=max | |
- name: Build and push ce-workspace SL7 | |
id: docker_build_ce_workspace | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
#platforms: linux/amd64 | |
context: workspaces | |
file: workspaces/ce-workspace/Dockerfile | |
tags: glideinwms/ce-workspace:sl7_${{env.DH_LABEL}} | |
build-args: | | |
BUILD_SHA=${{env.GITHUB_SHA}} | |
BUILD_HASH=${{env.GITHUB_HASH}} | |
BUILD_REF=${{env.GITHUB_REF}} | |
BUILD_DATE=${{env.BUILD_DATE}} | |
GWMS_VERSION=sl7_${{env.DH_LABEL}} | |
- name: Build and push factory-workspace SL7 | |
id: docker_build_factory_workspace | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
#platforms: linux/amd64 | |
context: workspaces | |
file: workspaces/factory-workspace/Dockerfile | |
tags: glideinwms/factory-workspace:sl7_${{env.DH_LABEL}} | |
build-args: | | |
BUILD_SHA=${{env.GITHUB_SHA}} | |
BUILD_HASH=${{env.GITHUB_HASH}} | |
BUILD_REF=${{env.GITHUB_REF}} | |
BUILD_DATE=${{env.BUILD_DATE}} | |
GWMS_VERSION=sl7_${{env.DH_LABEL}} | |
- name: Build and push frontend-workspace SL7 | |
id: docker_build_frontend_workspace | |
uses: docker/build-push-action@v6 | |
with: | |
push: true | |
#platforms: linux/amd64 | |
context: workspaces | |
file: workspaces/frontend-workspace/Dockerfile | |
tags: glideinwms/frontend-workspace:sl7_${{env.DH_LABEL}} | |
build-args: | | |
BUILD_SHA=${{env.GITHUB_SHA}} | |
BUILD_HASH=${{env.GITHUB_HASH}} | |
BUILD_REF=${{env.GITHUB_REF}} | |
BUILD_DATE=${{env.BUILD_DATE}} | |
GWMS_VERSION=sl7_${{env.DH_LABEL}} |