Skip to content

Fix GitHub action error in posting the container when merged to main #1260

Fix GitHub action error in posting the container when merged to main

Fix GitHub action error in posting the container when merged to main #1260

Workflow file for this run

name: DOC
on:
push:
branches:
- main
- develop
- 'release/*'
tags:
- '*'
pull_request:
branches:
- main
- develop
- 'release/*'
env:
MAIN_REPO: IN-CORE/pyincore
jobs:
# ----------------------------------------------------------------------
# DOCKER BUILD
# ----------------------------------------------------------------------
docker:
runs-on: ubuntu-latest
steps:
# checkout source code
- uses: actions/checkout@v4
# calculate some variables that are used later
- name: version information
run: |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
BRANCH="${{ github.event.release.target_commitish }}"
elif [[ $GITHUB_REF =~ pull ]]; then
BRANCH="$(echo $GITHUB_REF | sed 's#refs/pull/\([0-9]*\)/merge#PR-\1#')"
else
BRANCH=${GITHUB_REF##*/}
fi
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
if [ "$BRANCH" == "main" ]; then
version=$(awk -F= '/^release/ { print $2}' docs/source/conf.py | sed "s/[ ']//g")
tags="latest"
oldversion=""
while [ "${oldversion}" != "${version}" ]; do
oldversion="${version}"
tags="${tags},${version}"
version=${version%.*}
done
# Remove any unwanted double quotes from tags
tags=$(echo $tags | sed 's/"//g')
echo "VERSION=${version}" >> $GITHUB_ENV
echo "TAGS=${tags}" >> $GITHUB_ENV
elif [ "$BRANCH" == "develop" ]; then
echo "VERSION=develop" >> $GITHUB_ENV
echo "TAGS=develop" >> $GITHUB_ENV
else
echo "VERSION=testing" >> $GITHUB_ENV
echo "TAGS=${BRANCH}" >> $GITHUB_ENV
fi
# debug TAGS
- name: Debug TAGS
run: echo "TAGS=${{ env.TAGS }}"
# build image
- name: Build image
uses: elgohr/Publish-Docker-Github-Action@3.04
with:
name: incore/doc/pyincore
no_push: true
# this will publish to NCSA
- name: Publish to NCSA Hub
#if: github.event_name != 'pull_request' && github.repository == env.MAIN_REPO
if: github.repository == env.MAIN_REPO
uses: elgohr/Publish-Docker-Github-Action@3.04
env:
BRANCH: ${{ env.GITHUB_BRANCH }}
VERSION: ${{ env.VERSION }}
BUILDNUMBER: ${{ github.run_number }}
GITSHA1: ${{ github.sha }}
with:
registry: hub.ncsa.illinois.edu
name: incore/doc/pyincore
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_PASSWORD }}
tags: "${{ env.TAGS }}"
buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1