Publish to DockerHub #5
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
name: Publish to DockerHub | |
on: | |
workflow_call: | |
inputs: | |
semvertag: | |
required: true | |
type: string | |
images: | |
required: false | |
type: string | |
secrets: | |
DOCKERHUB_USERNAME: | |
required: true | |
DOCKERHUB_TOKEN: | |
required: true | |
workflow_dispatch: | |
inputs: | |
semvertag: | |
required: true | |
type: string | |
description: "semantic version tag" | |
images: | |
required: false | |
type: string | |
description: "image name" | |
secrets: | |
DOCKERHUB_USERNAME: | |
required: true | |
DOCKERHUB_TOKEN: | |
required: true | |
jobs: | |
push_to_registry: | |
name: Push Docker image to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- | |
name: Get images param or set default | |
id: getimages | |
run: | | |
IMAGES_INPUT=${{ inputs.images }} | |
echo "images=${IMAGES_INPUT:-jeffersonlab/${{ github.event.repository.name }}}" >> $GITHUB_OUTPUT | |
- | |
name: Checkout | |
uses: actions/checkout@v4 | |
- | |
name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
${{ steps.getimages.outputs.images }} | |
tags: | | |
type=semver,pattern={{version}},event=release | |
type=semver,pattern={{version}},event=workflow_dispatch | |
type=semver,pattern={{version}},event=workflow_call,value=${{ inputs.semvertag }} | |
- | |
name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- | |
name: Push to Docker Hub | |
uses: docker/build-push-action@v5 | |
with: | |
push: true | |
build-args: | | |
CUSTOM_CRT_URL=http://pki.jlab.org/JLabCA.crt | |
tags: ${{ steps.meta.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels }} | |
- | |
name: Update demo version | |
run: | | |
git config --local user.name "github-actions[bot]" | |
git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
git fetch origin main | |
git checkout main | |
sed -i -E 's/[0-9]+(\.[0-9]+)*/${{ steps.meta.outputs.version }}/' compose.override.yaml | |
git commit -am "Bump demo compose version to ${{ steps.meta.outputs.version }}" | |
git push |