Publish Turing Docker Image #6
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 binary | |
uses: actions/download-artifact@v2 | |
with: | |
name: oak-collator | |
- 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") | .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 $artifact_url | |
ls -lah | |
# 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:abcdef | |
# oaknetwork/turing:2.0.0-abcdef | |
# | |
# 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 push 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 | |
# oaknetwork/turing:2.0.0 | |
- name: Push latest tag to docker hub | |
run: | | |
# TODO : remove echo after test | |
echo docker tag oaknetwork/turing:${GITHUB_SHA} oaknetwork/turing:${docker_tag} | |
echo docker push oaknetwork/turing:$docker_tag | |
echo docker tag oaknetwork/turing:$docker_tag oaknetwork/turing:latest | |
echo docker push oaknetwork/turing:latest | |
if: ${{ inputs.draft == false }} |