Deploy Images to DockerHub #1
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: Deploy Images to DockerHub | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: 'Tag to use' | |
required: true | |
type: string | |
env: | |
GITHUB_WORKFLOW_FOLDER: ./.github/workflows | |
JEMPI_APP_PATH: ./JeMPI_Apps | |
defaults: | |
run: | |
shell: bash | |
jobs: | |
prepare: | |
runs-on: ubuntu-22.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/workflows/actions/prepare | |
build-deploy-images: | |
runs-on: ubuntu-22.04 | |
needs: [prepare] | |
steps: | |
- uses: actions/checkout@v4 | |
- id: validate-tag | |
run: | | |
CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD) | |
if [ "$CURRENT_BRANCH" != "main" ] && [ "$CURRENT_BRANCH" != "master" ]; then | |
echo "Can only do a manual deployment on main / master. Exiting." | |
exit 1 | |
fi | |
git fetch --tags | |
if git rev-parse -q --verify "refs/tags/${{ inputs.tag }}" > /dev/null; then | |
echo "image-build-tag=$(git rev-parse --abbrev-ref HEAD)-$(git log -1 --pretty=format:%h)" >> $GITHUB_OUTPUT | |
echo "docker-push-tag=${{ inputs.tag }}" >> $GITHUB_OUTPUT | |
else | |
echo "The tag '${{ inputs.tag }}' does not exist on the branch '$GITHUB_REF_NAME'" | |
exit 1 | |
fi | |
- uses: ./.github/workflows/actions/build-deploy-images | |
with: | |
image-build-tag: ${{ steps.validate-tag.outputs.image-build-tag }} | |
docker-push-tag: ${{ steps.validate-tag.outputs.docker-push-tag }} | |
docker-host: "docker.io" | |
docker-username: ${{ secrets.DOCKER_HUB_USER_NAME }} | |
docker-password: ${{ secrets.DOCKER_HUB_PASSWORD }} |