Skip to content

Fixed git links to work with any python version, including py36 in S… #19

Fixed git links to work with any python version, including py36 in S…

Fixed git links to work with any python version, including py36 in S… #19

# 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-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
#
# TODO: reduce run times, these allow filters at the job level:
# https://github.com/tj-actions/changed-files
# https://github.com/dorny/paths-filter
# TODO: single wf also sl7 on-pull setting variable? DH_OS env? image name, tag name, platform list
name: Build and Push Workspaces
on:
push:
branches: [main ]
paths: ['workspaces/**']
pull_request:
branches: [main ]
paths: ['workspaces/**']
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
sl7_build:
description: 'True if building for CentOS7/SL7'
required: true
default: false
type: boolean
repository_dispatch:
types:
- workspaces-build
env:
DH_LABEL: latest
DH_PREFIX: ''
DH_PLATFORMS: linux/amd64,linux/arm64
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
- name: set variables for SL7 build from inputs
id: setsl7_inputs
continue-on-error: true
if: ${{ inputs.sl7_build }}
run: |
echo "DH_PREFIX=sl7_" >> $GITHUB_ENV
echo "DH_PLATFORMS=linux/amd64" >> $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-
- 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
id: docker_build_gwms_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/gwms-workspace/Dockerfile
tags: glideinwms/gwms-workspace:${{env.DH_PREFIX}}${{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=${{env.DH_PREFIX}}${{env.DH_LABEL}}
#cache-from: type=gha
#cache-to: type=gha,mode=max
- name: Build and push ce-workspace
id: docker_build_ce_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/ce-workspace/Dockerfile
tags: glideinwms/ce-workspace:${{env.DH_PREFIX}}${{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=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push factory-workspace
id: docker_build_factory_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/factory-workspace/Dockerfile
tags: glideinwms/factory-workspace:${{env.DH_PREFIX}}${{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=${{env.DH_PREFIX}}${{env.DH_LABEL}}
- name: Build and push frontend-workspace
id: docker_build_frontend_workspace
uses: docker/build-push-action@v6
with:
push: true
platforms: ${{env.DH_PLATFORMS}}
context: workspaces
file: workspaces/frontend-workspace/Dockerfile
tags: glideinwms/frontend-workspace:${{env.DH_PREFIX}}${{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=${{env.DH_PREFIX}}${{env.DH_LABEL}}