Skip to content

Commit

Permalink
test update core
Browse files Browse the repository at this point in the history
  • Loading branch information
jo-bisonai committed May 29, 2024
1 parent 2c06f78 commit 3c2d549
Showing 1 changed file with 191 additions and 0 deletions.
191 changes: 191 additions & 0 deletions .github/workflows/core.image+upload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
name: Dispatch Deploy

on:
workflow_dispatch:
inputs:
application:
description: "Application to deploy"
required: true
type: choice
options:
- "cli"
- "aggregator"
- "vrf"
- "api"
- "request-response"
- "delegator"
- "fetcher"
- "por"
- "node"
- "boot-api"
- "sentinel"
network:
description: "Network to deploy to"
required: true
type: choice
options:
- "Baobab"
- "Cypress"

jobs:
prepare:
name: Prepare
runs-on: ubuntu-latest
if: ${{ github.event.inputs.network == 'Baobab' }}

outputs:
tag_date: ${{ steps.tag.outputs.date }}
tag_git_hash: ${{ steps.tag.outputs.git_hash }}
service: ${{ steps.tag.outputs.service }}
ecr_url: ${{ steps.tag.outputs.ecr_url }}
version: ${{ steps.package.outputs.version }}

steps:
- uses: actions/checkout@master

- name: Get time TAG
id: tag
run: |
echo "date=$(date +'%Y%m%d.%H%M')" >> $GITHUB_OUTPUT
echo "git_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
service="${{ github.event.inputs.application }}"
if [[ "${{ github.event.inputs.application }}" == "vrf" || "${{ github.event.inputs.application }}" == "request-response" || "${{ github.event.inputs.application }}" == "aggregator" ]]; then
service="core"
fi
echo "service=$service" >> $GITHUB_OUTPUT
echo "ecr_url=public.ecr.aws/bisonai/orakl-${service}" >> $GITHUB_OUTPUT
- name: Get package version
id: package
run: |
if [[ "${{ steps.tag.outputs.service }}" == "cli" || "${{ steps.tag.outputs.service }}" == "fetcher" || "${{ steps.tag.outputs.service }}" == "core" ]]; then
echo "version=$(node -p -e "require('./"${{ steps.tag.outputs.service }}"/package.json').version")" >> $GITHUB_OUTPUT
else
if [[ "${{ steps.tag.outputs.service }} "" == "boot-api"]]; then
version=$(cat ./node/.version)
else
version=$(cat ./"${{ steps.tag.outputs.service }}"/.version)
fi
echo "version=$version" >> $GITHUB_OUTPUT
fi
build:
name: Build
runs-on: ubuntu-latest
needs: prepare
if: ${{ github.event.inputs.network == 'Baobab' }}

permissions:
id-token: write
contents: read

outputs:
img_tag: ${{ steps.img-tag.outputs.img_tag }}

steps:
- uses: actions/checkout@master

- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: "1.22.3"
check-latest: true
cache-dependency-path: |
./${{ needs.prepare.outputs.service }}/go.sum
./${{ needs.prepare.outputs.service }}/go.mod
if: ${{ needs.prepare.outputs.service != 'core' || needs.prepare.outputs.service != 'fetcher' || needs.prepare.outputs.service != 'cli' }}

- name: docker build ${{ inputs.application }}
run: SERVICE_NAME=orakl-${{ needs.prepare.outputs.service }} docker compose -f docker-compose.build.yaml build

- name: configure aws credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-east-1
role-to-assume: ${{ secrets.ROLE_ARN }}

- name: login to amazon ecr
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v1
with:
registry-type: public

- name: publish image to ecr
run: |
docker tag orakl-${{ needs.prepare.outputs.service }} ${{ needs.prepare.outputs.ecr_url }}:latest
docker push ${{ needs.prepare.outputs.ecr_url }}:latest
docker tag ${{ needs.prepare.outputs.ecr_url }}:latest ${{ needs.prepare.outputs.ecr_url }}:v${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }}
docker push ${{ needs.prepare.outputs.ecr_url }}:v${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }}
- name: image tag output
id: img-tag
run: echo "img_tag=v${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }}" >> $GITHUB_OUTPUT

post-slack-image-upload:
name: Slack message for image upload
needs: [prepare, build]
uses: ./.github/workflows/post.slack.yaml
with:
status: "Success"
slack-message: "${{ github.event.inputs.network }} ${{ github.event.inputs.application }}* : *${{ needs.prepare.outputs.service }}* ${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }} is uploaded"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
if: ${{ github.event.inputs.network == 'Baobab' && success() }}

image-update:
name: Update image tag
needs: [prepare, build]
uses: ./.github/workflows/update.image-tag.yaml
with:
network: "baobab"
project-name: ${{ github.event.inputs.application }}
version: ${{ needs.prepare.outputs.version }}
image-tag: ${{ needs.build.outputs.img_tag }}
tag_date: ${{ needs.prepare.outputs.tag_date }}
tag_git_hash: ${{ needs.prepare.outputs.tag_git_hash }}
secrets:
PAT: ${{ secrets.PAT }}
if: ${{ github.event.inputs.network == 'Baobab' }}

post-slack-baobab-tag-update-success:
name: Post slack message for tag update success
needs: [prepare, build, image-update]
uses: ./.github/workflows/post.slack.yaml
with:
status: "Success"
slack-message: "${{ github.event.inputs.network }} *${{ github.event.inputs.application }}* : *${{ needs.prepare.outputs.service }}* new image tag ${{ needs.prepare.outputs.version }}.${{ needs.prepare.outputs.tag_date }}.${{ needs.prepare.outputs.tag_git_hash }} is updated"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
if: ${{ github.event.inputs.network == 'Baobab' && success() }}

cypress-image-update:
name: cypress image update
uses: ./.github/workflows/update.image-tag.yaml
with:
network: "cypress"
project-name: ${{ github.event.inputs.application }}
secrets:
PAT: ${{ secrets.PAT }}
if: ${{ github.event.inputs.network == 'Cypress' }}

post-slack-cypress-tag-update-success:
name: Post slack message for tag update success
needs: [cypress-image-update]
uses: ./.github/workflows/post.slack.yaml
with:
status: "Success"
slack-message: "${{ github.event.inputs.network }} *${{ github.event.inputs.application }}* is updated"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
if: ${{ github.event.inputs.network == 'Cypress' && success() }}

post-slack-tag-update-failure:
name: Post to a slack message for tag update failure
needs: [prepare, build, image-update]
uses: ./.github/workflows/post.slack.yaml
with:
status: "Failed"
slack-message: "${{ github.event.inputs.network }} *${{ github.event.inputs.application }}* git action failed"
secrets:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
if: ${{ github.event.inputs.network == 'Baobab' && failure() }}

0 comments on commit 3c2d549

Please sign in to comment.