Release image to DockerHub #72
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: Release image to DockerHub | |
on: | |
workflow_dispatch: | |
inputs: | |
tag: | |
description: "Image tag" | |
required: true | |
commit_sha: | |
description: "Commit SHA" | |
required: true | |
workflow_run: | |
workflows: ["Build on ubuntu"] | |
types: | |
- completed | |
branches: [master, "[0-9]+.[0-9]+"] | |
release: | |
types: [published] | |
env: | |
BUILD_WORKFLOW_NAME: build.yml | |
# Get the commit SHA from the event that triggered the workflow | |
# If the event is a workflow_dispatch, use the input value | |
# If the event is a workflow_run, use the head_commit.id | |
# If the event is a release, use the target_commitish | |
COMMIT_SHA: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.commit_sha || github.event_name == 'workflow_run' && github.event.workflow_run.head_commit.id || github.event_name == 'release' && github.sha || github.sha }} | |
jobs: | |
release: | |
# Only run this job if the workflow_run event is successful or if the event is not a workflow_run | |
if: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success' || github.event_name != 'workflow_run' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retrieve built image AMD | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
workflow: ${{ env.BUILD_WORKFLOW_NAME }} | |
commit: ${{ env.COMMIT_SHA }} | |
workflow_conclusion: success | |
name: falkordb-x64 | |
path: /tmp | |
if_no_artifact_found: error | |
- name: Retrieve built image ARM | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
workflow: ${{ env.BUILD_WORKFLOW_NAME }} | |
commit: ${{ env.COMMIT_SHA }} | |
workflow_conclusion: success | |
name: falkordb-arm64v8 | |
path: /tmp | |
if_no_artifact_found: error | |
- name: Load image | |
run: | | |
docker load -i /tmp/falkordb-x64.tar | |
docker load -i /tmp/falkordb-arm64v8.tar | |
- name: Login to DockerHub | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_PASSWORD }} | |
- name: Set tag name | |
id: set_tag | |
run: | | |
# If the event is a release, use the release tag name | |
if [ "${{ github.event_name }}" == "release" ]; then | |
TAG_NAME=${{ github.event.release.tag_name }} | |
echo "IS_LATEST=1" >> $GITHUB_ENV | |
fi | |
# If the event is a workflow_dispatch, use the input value | |
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
TAG_NAME=${{ github.event.inputs.tag }} | |
fi | |
# If the event is a workflow_run, and branch is master, set to "edge" | |
if [ "${{ github.event_name }}" == "workflow_run" ] && [ "${{ github.event.workflow_run.head_branch }}" == "master" ]; then | |
TAG_NAME="edge" | |
fi | |
# If the event is a workflow_run, and branch is not master, set to the branch name | |
if [ "${{ github.event_name }}" == "workflow_run" ] && [ "${{ github.event.workflow_run.head_branch }}" != "master" ]; then | |
TAG_NAME="v${{ github.event.workflow_run.head_branch }}" | |
fi | |
echo "TAG_NAME=${TAG_NAME}" >> $GITHUB_ENV | |
- name: Tag x64 and ARM images | |
run: | | |
docker tag falkordb/falkordb-x64 falkordb/falkordb:${{ env.TAG_NAME }}-x64 | |
docker tag falkordb/falkordb-arm64v8 falkordb/falkordb:${{ env.TAG_NAME }}-arm64v8 | |
- name: Push x64 and ARM images & create manifest | |
run: | | |
docker push falkordb/falkordb:${{ env.TAG_NAME }}-x64 | |
docker push falkordb/falkordb:${{ env.TAG_NAME }}-arm64v8 | |
docker buildx imagetools create -t falkordb/falkordb:${{ env.TAG_NAME }} ${{ env.IS_LATEST == '1' && '-t falkordb/falkordb:latest' || '' }} \ | |
falkordb/falkordb:${{ env.TAG_NAME }}-x64 \ | |
falkordb/falkordb:${{ env.TAG_NAME }}-arm64v8 | |
- name: Inspect image | |
run: | | |
docker buildx imagetools inspect falkordb/falkordb:${{ env.TAG_NAME }} |