Skip to content

Manual Docker Container Build #7

Manual Docker Container Build

Manual Docker Container Build #7

Workflow file for this run

name: Manual Docker Container Build
on:
workflow_dispatch:
inputs:
push_to_where:
description: 'Type either "dockerhub" or "github" to push to the respective registry'
default: 'github'
required: true
type: string
env:
MAIN_REPO: ncsa/standalone-smm-analytics
jobs:
# ----------------------------------------------------------------------
# DOCKER BUILD
# ----------------------------------------------------------------------
docker:
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
name:
- autophrase
include:
- name: autophrase
dockerfile: Dockerfile
workdir: containerized_analytics/smile/autophrase
docker_repo_tag: socialmediamacroscope/autophrase
github_repo_tag: ncsa/autophrase
steps:
# checkout source code
- uses: actions/checkout@v2
# calculate version information
- name: version information
run: |
if [ "${{ github.event.release.target_commitish }}" != "" ]; then
BRANCH="PR-${{github.event.pull_request.number}}"
elif [[ "${{github.event_name}}" == "pull_request" ]]; then
BRANCH="PR-${{github.event.pull_request.number}}"
else
BRANCH=${GITHUB_REF##*/}
echo "this hit"
fi
echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV
if [ "$BRANCH" == "main" ]; then
VERSION=$(cat manual_jb/content/_config.yml | grep "version" | head -1 | awk -F= "{print $2 }" | sed "s/[[:alpha:]|,|-|\"|:|#|[:space:]]//g" | sed "s/-//g")
VERSIONS="latest"
OLDVERSION=""
TMPVERSION=$VERSION
while [ "$OLDVERSION" != "$TMPVERSION" ]; do
VERSIONS="${VERSIONS} ${TMPVERSION}"
OLDVERSION="${TMPVERSION}"
TMPVERSION=$(echo ${OLDVERSION} | sed 's/\.[0-9]*$//')
done
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "TAGS=${VERSIONS}" >> $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
- name: Print Version tag
run: |
echo "${{ env.TAGS }}"
echo "${{ inputs.push_to_where }}"
echo "HUBPUSH=${{ inputs.push_to_where }}" >> $GITHUB_ENV
# login to registries
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build docker image
if: |
env.HUBPUSH == 'github' || env.HUBPUSH == 'dockerhub'
uses: elgohr/[email protected]
with:
dockerfile: ${{ matrix.dockerfile }}
name: ${{ matrix.docker_repo_tag }}
no_push: true
workdir: ${{ matrix.workdir }}
- name: Publish doc image to Docker Hub
if: |
env.HUBPUSH == 'dockerhub'
uses: elgohr/[email protected]
with:
registry: docker.io
name: ${{ matrix.docker_repo_tag }}
username: ${{ secrets.HUB_USERNAME }}
password: ${{ secrets.HUB_PASSWORD }}
tags: "${{ env.TAGS }}"
workdir: ${{ matrix.workdir }}
- name: Publish doc image to Github
if: |
env.HUBPUSH == 'github'
uses: elgohr/[email protected]
with:
registry: ghcr.io
name: ${{ matrix.github_repo_tag }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
tags: "${{ env.TAGS }}"
workdir: ${{ matrix.workdir }}