Skip to content

nciccbr/ccbr_ubuntu_base_20.04:v7 #6

nciccbr/ccbr_ubuntu_base_20.04:v7

nciccbr/ccbr_ubuntu_base_20.04:v7 #6

name: build-docker-manual
run-name: ${{ inputs.namespace }}/${{ inputs.image_name }}:${{ inputs.version }}
on:
workflow_dispatch:
inputs:
dockerfile:
type: string
description: path to the Dockerfile in the repo (e.g. common/ccbr_bwa/Dockerfile)
required: true
namespace:
type: string
description: namespace on dockerhub
required: true
default: nciccbr
image_name:
type: string
description: container image name (e.g. ccbr_toolname)
required: true
version:
type: string
description: container version tag (e.g. 1.0.0)
required: true
push:
type: boolean
description: Push to DockerHub (leave unchecked to just build the container without pushing)
required: true
jobs:
build-docker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Login to DockerHub
if: ${{ github.event.inputs.push == 'true' }}
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Prepare build-time variables
id: vars
run: |
if [ ! -f ${{ github.event.inputs.dockerfile }} ] ; then
echo "ERROR: Dockerfile not found: ${{ github.event.inputs.dockerfile }}"
exit 1
fi
echo "CONTEXT=$(dirname ${{ github.event.inputs.dockerfile }})" >> "$GITHUB_OUTPUT"
echo "DATE=$(date +"%Y-%m-%d")" >> "$GITHUB_OUTPUT"
$ for Docker Hub Description
echo " # ${{ github.repository }} ${{ github.event.inputs.image_name }}\n" > tmp_README.md
echo "Dockerfile source: https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${{ github.event.inputs.dockerfile }}\n" >> tmp_README.md
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ${{ steps.vars.outputs.CONTEXT }}
file: ${{ github.event.inputs.dockerfile }}
push: ${{ github.event.inputs.push }}
tags: ${{ github.event.inputs.namespace }}/${{ github.event.inputs.image_name }}:${{ github.event.inputs.version }}
build-args: |
BUILD_DATE=${{ steps.vars.outputs.DATE }}
BUILD_TAG=${{ github.event.inputs.version }}
REPONAME=${{ github.event.inputs.image_name }}
- name: Update Docker Hub Description
if: ${{ github.event.inputs.push == 'true' }}
uses: peter-evans/dockerhub-description@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
repository: peterevans/dockerhub-description
readme-filepath: tmp_README.md