Skip to content

DockerHub-deploy

DockerHub-deploy #169

Workflow file for this run

# This job builds and deploys Docker image to DockerHub
name: DockerHub-deploy
on:
workflow_run:
workflows: ['CI Master branch'] # runs after CI workflow
types:
- completed
permissions:
contents: read # Required for actions/checkout to read the repository
actions: read # Required to download artifacts from the triggering workflow
packages: write # Required for pushing Docker images to DockerHub
jobs:
on-success:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 # checkout from Git
with:
ref: master # Always checks out the master branch (due to config file)
- name: Download a JAR file to deploy # download `evita-server.jar` artifact if the workflow we react to was successful
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: evita-server.jar
path: docker
- name: Download a version information # download `version.txt` artifact if the workflow we react to was successful
uses: dawidd6/action-download-artifact@20319c5641d495c8a52e688b7dc5fada6c3a9fbc # v8
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
workflow_conclusion: success
name: version.txt
- name: Set up QEMU
# Add support for more platforms with QEMU (optional)
# https://github.com/docker/setup-qemu-action
uses: docker/setup-qemu-action@53851d14592bedcffcf25ea515637cff71ef929a # v3.3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@6524bf65af31da8d45b59e8c27de4bd072b392f5 # v3.8.0
with:
buildkitd-flags: --debug
platforms: linux/amd64,linux/arm64/v8
- name: Login to DockerHub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3.3.0
with:
username: ${{ vars.CI_REGISTRY_USER }}
password: ${{ secrets.CI_REGISTRY_PASSWORD }}
- name: Extract major version
id: major_version
# create a new output variable with the major version (like 2024.4)
run: |
if ! grep -Eq '^[0-9]{4}\.[0-9]+\.[0-9]+$' version.txt; then
echo "Invalid version format in version.txt"
exit 1
fi
export sanitizedVersionContents=$(tr -d '\r\n' < version.txt)
fullVersion=$sanitizedVersionContents
version=$(echo "$sanitizedVersionContents" | cut -d '.' -f1,2)
echo "fullVersion=$fullVersion" >> "$GITHUB_ENV"
echo "version=$version" >> "$GITHUB_ENV"
releaseDate=$(date +%Y-%m-%d)
echo "releaseDate=$releaseDate" >> "$GITHUB_ENV"
- name: Build and push Docker image
env:
RELEASE_IMAGE: "evitadb:latest"
EVITA_JAR_NAME: evita-server.jar
uses: docker/build-push-action@ca877d9245402d1537745e0e356eab47c3520991 # v6.13.0
with:
context: ./docker
file: ./docker/Dockerfile
pull: true
push: true
# push the image with two tags: latest and the version from the version.txt file
tags: |
${{ vars.CI_REGISTRY_USER }}/${{ env.RELEASE_IMAGE }}
${{ vars.CI_REGISTRY_USER }}/evitadb:${{ env.version }}
${{ vars.CI_REGISTRY_USER }}/evitadb:${{ env.fullVersion }}
platforms: linux/amd64,linux/arm64/v8
build-args: |
EVITA_JAR_NAME=${{ env.EVITA_JAR_NAME }}
VERSION=${{ env.fullVersion }}
RELEASE_DATE=${{ env.releaseDate }}