Skip to content
name: Build and publish Docker image for Release
on:
# Trigger the workflow on push or pull request,
# for the develop branch and all new tags
push:
tags:
- v*
- preview-*
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Fetch Prune Unshallow Tags
run: git fetch --prune --unshallow --tags
- name: Extract github metadata GITHUB_SHA, GIT_BRANCH, GIT_TAG
shell: bash
run: |
echo "GIT_COMMIT_SHA=${GITHUB_SHA}" >> $GITHUB_ENV
echo "GIT_REMOTE_URL=$(git config --get remote.origin.url)" >> $GITHUB_ENV
echo "GIT_BRANCH=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_ENV
echo "GIT_TAG=$(echo ${GITHUB_REF#refs/tags/})" >> $GITHUB_ENV
echo "BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ')" >> $GITHUB_ENV
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
env:
GIT_COMMIT_SHA: ${{ env.GIT_COMMIT_SHA }}
GIT_REMOTE_URL: ${{ env.GIT_REMOTE_URL }}
GIT_BRANCH: ${{ env.GIT_BRANCH }}
GIT_TAG: ${{ env.GIT_TAG }}
BUILD_DATE: ${{ env.BUILD_DATE }}
with:
name: c2dhunilu/journal-of-digital-history
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
buildargs: |
GIT_COMMIT_SHA, GIT_REMOTE_URL, GIT_BRANCH, GIT_TAG, BUILD_DATE
tags: '${{ env.GIT_TAG }}'