Skip to content

Merge pull request #121 from 0chain/feat/update-readme #406

Merge pull request #121 from 0chain/feat/update-readme

Merge pull request #121 from 0chain/feat/update-readme #406

name: build-&-publish-minio-client-docker-image
# concurrency:
# group: "publish-${{ github.ref }}"
# cancel-in-progress: true
on:
push:
branches: [ master,staging, sprint* ]
tags: [ "v*.*.*" ]
pull_request:
workflow_dispatch:
inputs:
staging_tag:
description: 'type yes for building staging tag'
default: 'no'
required: true
env:
MINIO_CLIENT_REGISTRY: ${{ secrets.MINIO_CLIENT_REGISTRY }}
jobs:
dockerize_client:
runs-on: [self-hosted, arc-runner]
outputs:
output1: ${{ steps.docker_build.outputs.COMMIT_TAG }}
steps:
- uses: actions/checkout@v1
- name: Set Docker Image Tags.
id: get_info
run: |
if [[ "${{github.ref}}" == refs/pull/* ]]; then
tag=${GITHUB_REF/\/merge/}
echo "TAG=$(echo pr-${tag:10})" >> $GITHUB_ENV
else
echo "TAG=$(echo ${GITHUB_REF#refs/*/} | sed 's/\//-/g')" >> $GITHUB_ENV
fi
echo "BRANCH=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo ${GITHUB_REF#refs/*/} || echo $GITHUB_HEAD_REF)" >> $GITHUB_ENV
echo "SHA=$([ -z '${{ github.event.pull_request.head.sha }}' ] && echo $GITHUB_SHA || echo '${{ github.event.pull_request.head.sha }}')" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build & Push Docker Image.
id: docker_build
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
cd client-api
docker build -t $MINIO_CLIENT_REGISTRY:latest .
docker tag $MINIO_CLIENT_REGISTRY:latest $MINIO_CLIENT_REGISTRY:$TAG-$SHORT_SHA
docker tag $MINIO_CLIENT_REGISTRY:latest $MINIO_CLIENT_REGISTRY:$TAG
docker push $MINIO_CLIENT_REGISTRY:$TAG-$SHORT_SHA
docker push $MINIO_CLIENT_REGISTRY:$TAG
- name: Push latest
if: ${{ github.event.inputs.latest_tag == 'yes' || github.ref == 'refs/heads/master' }}
run: |
docker push ${{ secrets.MINIO_CLIENT_REGISTRY }}:latest
- name: Push staging
if: ${{ github.event.inputs.latest_tag == 'yes' || github.ref == 'refs/heads/staging' }}
run: |
docker tag $MINIO_CLIENT_REGISTRY:latest $MINIO_CLIENT_REGISTRY:staging
docker push ${{ secrets.MINIO_CLIENT_REGISTRY }}:staging
- name: "Checkout zcnwebappscripts CLI"
if: github.ref == 'refs/heads/staging'
uses: actions/checkout@v2
with:
ref: main
repository: 0chain/zcnwebappscripts
fetch-depth: 1
path: ./zcnwebappscripts
- name: Change image tag in blimp.sh of zcnwebappscripts
if: github.ref == 'refs/heads/staging'
run: |
SHORT_SHA=$(echo ${{ env.SHA }} | head -c 8)
echo $TAG-$SHORT_SHA
cd zcnwebappscripts
sed -i "s,DOCKER_IMAGE=.*,DOCKER_IMAGE=$TAG-$SHORT_SHA,g" "blimp.sh"
# - name: Pushes blimp.sh file
# if: github.ref == 'refs/heads/staging'
# uses: dmnemec/copy_file_to_another_repo_action@main
# env:
# API_TOKEN_GITHUB: ${{ secrets.ACCESS_TOKEN }}
# with:
# source_file: 'zcnwebappscripts/blimp.sh'
# destination_repo: '0chain/zcnwebappscripts'
# destination_folder: 'script'
# destination_branch: 'update/image-tag-script'
# user_email: 'zus@test.com'
# user_name: 'zus'
# commit_message: 'Update Image tag in script'
- name: Raise PR
if: github.ref == 'refs/heads/staging'
run: |
curl -X POST \
-H "Authorization: Bearer ${{secrets.ACCESS_TOKEN}}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/0chain/zcnwebappscripts/actions/workflows/raise_pr.yaml/dispatches \
-d '{"ref": "main"}'
- name: Clean Up The Workspace.
if: ${{ always() }}
run: |
rm -rf ./*