Build docker images #33
Workflow file for this run
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
# Builds and publish cmsmonitoring/spark2mng and/or cmsmonitoring/rucio-mon-goweb docker images | |
# Works only with git tag commit messages | |
# - "Build docker all": builds spark2mng and rucio-mon-goweb | |
# - "Build docker (goweb) foo bla": builds only rucio-mon-goweb | |
# - "Build docker (spark) foo bla": builds only spark2mng | |
name: Build docker images | |
on: | |
push: | |
tags: | |
- 'rgo-*.*.*' | |
jobs: | |
init-job: | |
runs-on: ubuntu-latest | |
outputs: | |
git_tag: ${{ steps.step1.outputs.git_tag }} | |
action: ${{ steps.step1.outputs.action }} | |
docker_individual_images: ${{ steps.step1.outputs.individual_images }} | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- id: step1 | |
run: | | |
# Define git tag commit message regex rules that users should obey to use functionalities | |
# "\d" kind regex expressions does not work! | |
REGEX_BUILD_ALL='Build docker all.*' | |
REGEX_BUILD_INDIVIDUALS='Build docker [(](.+)[)].*' | |
# Get git tag and set as "git_tag" variable | |
echo "::set-output name=git_tag::${GITHUB_REF/refs\/tags\//}" | |
# Get tag commit message | |
GIT_TAG_MSG="$(git tag -l --format="%(contents)" $GITHUB_REF_NAME)" | |
echo "Tag message:" $GIT_TAG_MSG | |
# Check that tag commit message obeys regex rules | |
# Check all | |
if [[ $GIT_TAG_MSG =~ $REGEX_BUILD_ALL ]]; then | |
echo "Action: all" | |
echo "::set-output name=action::all" | |
exit 0 | |
fi | |
# Check individuals | |
if [[ $GIT_TAG_MSG =~ $REGEX_BUILD_INDIVIDUALS && ! -z "${BASH_REMATCH[1]}" ]]; then | |
echo "Action: individuals, individual_images: ${BASH_REMATCH[1]}" | |
echo "::set-output name=action::individuals" | |
echo "::set-output name=individual_images::${BASH_REMATCH[1]}" | |
exit 0 | |
fi | |
# Fail message | |
echo "failure, NO REGEX IS MATCHED WITH THE TAG MESSAGE" | |
build-rucio-mon-goweb: | |
runs-on: ubuntu-latest | |
needs: [ init-job ] | |
if: | | |
needs.init-job.outputs.action == 'all' || | |
contains(needs.init-job.outputs.docker_individual_images, 'goweb') | |
name: Build rucio-mon-goweb | |
steps: | |
- name: Set up Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '^1.20' | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Get rucio-mon-goweb Dockerfile | |
run: | | |
curl -ksLO https://raw.githubusercontent.com/dmwm/CMSKubernetes/master/docker/rucio-dataset-monitoring/Dockerfile-rucio-mon-goweb | |
- name: Login to registry.cern.ch | |
uses: docker/login-action@v1 | |
with: | |
registry: registry.cern.ch | |
username: ${{ secrets.CERN_LOGIN }} | |
password: ${{ secrets.CERN_TOKEN }} | |
- name: Publish rucio-mon-goweb image to registry.cern.ch | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile-rucio-mon-goweb | |
push: true | |
build-args: | | |
CMSMON_TAG=${{ needs.init-job.outputs.git_tag }} | |
tags: registry.cern.ch/cmsmonitoring/rucio-mon-goweb:${{ needs.init-job.outputs.git_tag }}, registry.cern.ch/cmsmonitoring/rucio-mon-goweb:latest | |
build-spark2mng: | |
runs-on: ubuntu-latest | |
needs: [ init-job ] | |
if: | | |
needs.init-job.outputs.action == 'all' || | |
contains(needs.init-job.outputs.docker_individual_images, 'spark') | |
name: Build spark2mng | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.ref }} | |
- name: Get spark2mng Dockerfile | |
run: | | |
curl -ksLO https://raw.githubusercontent.com/dmwm/CMSKubernetes/master/docker/rucio-dataset-monitoring/Dockerfile-spark2mng | |
- name: Login to registry.cern.ch | |
uses: docker/login-action@v1 | |
with: | |
registry: registry.cern.ch | |
username: ${{ secrets.CERN_LOGIN }} | |
password: ${{ secrets.CERN_TOKEN }} | |
- name: Publish spark2mng image to registry.cern.ch | |
uses: docker/build-push-action@v2 | |
with: | |
context: ./ | |
file: ./Dockerfile-spark2mng | |
push: true | |
build-args: | | |
CMSMON_TAG=${{ needs.init-job.outputs.git_tag }} | |
tags: registry.cern.ch/cmsmonitoring/spark2mng:${{ needs.init-job.outputs.git_tag }}, registry.cern.ch/cmsmonitoring/spark2mng:latest |