Publish Turing Docker Image #11
Workflow file for this run
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: Build& Relase Docker Image | |
on: | |
workflow_dispatch: | |
inputs: | |
relase_action_run_id: | |
required: true | |
description: "release action run id(the last number in URL of release action run) where we will download artifact from" | |
type: string | |
tag: | |
description: Tag for release | |
required: true | |
type: string | |
draft: | |
description: "in draft mode, we won't update the lastest tag" | |
required: true | |
default: 'true' | |
type: boolean | |
jobs: | |
build-docker: | |
permissions: | |
contents: 'read' | |
actions: 'read' | |
name: Build and Publish to Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Checkout | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.inputs.tag }} | |
- name: download artifact | |
run: | | |
artifact_url=$(curl -sL \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
https://api.github.com/repos/OAK-Foundation/OAK-blockchain/actions/runs/5803592718/artifacts | jq -r '.artifacts[] | select(.name == "oak-collator") | .archive_download_url ') | |
echo "Found artifact url for oak-collator ${artifact_url}" | |
curl \ | |
-sL \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-o oak-collator.zip $artifact_url | |
unzip oak-collator.zip | |
chmod +x ./oak-collator | |
- name: oak-collator version vs tag validation | |
run: | | |
# Ensure the version in the binary match the tag to avoid accidently publish wrong binary | |
version="${tag:1}" | |
./oak-collator --version | grep "oak-collator ${version}-" | |
# In draft mode we will push to below tag: | |
# reponame/imagename:{{git_revision}} | |
# reponame/imagename:{{tag}}-{{git_revision}} | |
# so we will have image such as | |
# oaknetwork/turing:2.0.0 | |
# | |
# and we can test these image | |
- name: Build | |
run: | | |
tag=${{ github.event.inputs.tag }} | |
docker build -f ./docker/turing/Dockerfile -t oaknetwork/turing:${GITHUB_SHA} . | |
docker_tag="${tag:1}" | |
docker tag oaknetwork/turing:${GITHUB_SHA} oaknetwork/turing:${docker_tag} | |
docker push oaknetwork/turing:$docker_tag | |
# when not in draft mode, we will update the pointer tag | |
# so we will have image such as | |
# oaknetwork/turing:latest | |
- name: Push latest tag to docker hub | |
run: | | |
# TODO : remove echo after test | |
docker_tag="${tag:1}" | |
echo docker tag oaknetwork/turing:${GITHUB_SHA} oaknetwork/turing:latest | |
echo docker push oaknetwork/turing:latest | |
if: ${{ inputs.draft == false }} |