From 1497ee93fda4999f68444b776291d14de3a46c9e Mon Sep 17 00:00:00 2001 From: Bob Jr Date: Thu, 11 Apr 2024 10:00:45 +0700 Subject: [PATCH] testnet: Continous deployment --- .../workflows/deploy-viction-by-codebuild.yml | 69 +++++++++++++++++++ .github/workflows/testnet.yml | 48 +++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 .github/workflows/deploy-viction-by-codebuild.yml create mode 100644 .github/workflows/testnet.yml diff --git a/.github/workflows/deploy-viction-by-codebuild.yml b/.github/workflows/deploy-viction-by-codebuild.yml new file mode 100644 index 0000000..aad1911 --- /dev/null +++ b/.github/workflows/deploy-viction-by-codebuild.yml @@ -0,0 +1,69 @@ +name: Deploy Docker Image By Codebuild + +on: + workflow_call: + inputs: + aws_region: + type: string + default: "ap-southeast-1" + aws_account_id: + required: true + type: string + aws_role_assume_name: + required: true + type: string + codebuild_project_name: + required: true + type: string + culiops_branch: + type: string + default: "main" + app_branch: + type: string + default: "master" + app_repo_name: + required: true + type: string + ecs_cluster_name: + type: string + default: "tomochain-testnet" + ecs_service_name: + required: true + type: string + +jobs: + codebuild: + runs-on: ubuntu-latest + steps: + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v2 + with: + aws-region: ${{ inputs.aws_region }} + role-to-assume: arn:aws:iam::${{ inputs.aws_account_id }}:role/${{ inputs.aws_role_assume_name }} + + - name: Get AWS caller identity + run: aws sts get-caller-identity + + - name: Trigger CodeBuild + uses: aws-actions/aws-codebuild-run-build@v1 + with: + project-name: ${{ inputs.codebuild_project_name }} + disable-source-override: true + env-vars-for-codebuild: | + AWS_DEFAULT_REGION, + AWS_ACCOUNT_ID, + CULIOPS_BRANCH, + ECS_CLUSTER_NAME, + BUILD_TYPE, + APP_BRANCH, + APP_REPO_NAME, + TRIGGERED_BY + env: + AWS_DEFAULT_REGION: ${{ inputs.aws_region }} + AWS_ACCOUNT_ID: ${{ inputs.aws_account_id }} + CULIOPS_BRANCH: ${{ inputs.culiops_branch }} + ECS_CLUSTER_NAME: ${{ inputs.ecs_cluster_name }} + BUILD_TYPE: ${{ inputs.ecs_service_name }} + APP_BRANCH: ${{ inputs.app_branch }} + APP_REPO_NAME: ${{ inputs.app_repo_name }} + TRIGGERED_BY: ${{ github.actor }} diff --git a/.github/workflows/testnet.yml b/.github/workflows/testnet.yml new file mode 100644 index 0000000..2d0552a --- /dev/null +++ b/.github/workflows/testnet.yml @@ -0,0 +1,48 @@ +name: Testnet +#Build and Deploy Viction Scan UI on Testnet + +on: workflow_dispatch + +env: + APPLICATION: "tomochain" + ENVIRONMENT: "testnet" + AWS_REGION: "ap-southeast-1" + CULIOPS_BRANCH: "main" + ECS_SERVICE_NAME: "issuer-web" + APP_REPO_NAME: "tomoissuer" + APP_BRANCH: "master" + +permissions: + id-token: write + contents: write + actions: write + +jobs: + set_vars: + runs-on: ubuntu-latest + outputs: + aws_region: ${{ env.AWS_REGION }} + aws_account_id: "604763758327" + aws_role_assume_name: "${{ env.APPLICATION }}-ci-${{ env.ENVIRONMENT }}" + codebuild_project_name: "${{ env.APPLICATION }}-${{ env.ENVIRONMENT }}" + culiops_branch: ${{ env.CULIOPS_BRANCH }} + ecs_cluster_name: "${{ env.APPLICATION }}-${{ env.ENVIRONMENT }}" + ecs_service_name: ${{ env.ECS_SERVICE_NAME }} + app_repo_name: ${{ env.APP_REPO_NAME }} + app_branch: ${{ env.APP_BRANCH }} + steps: + - run: echo "Exposing ENV vars" + + deploy: + needs: [set_vars] + uses: BuildOnViction/tomoissuer/.github/workflows/deploy-viction-by-codebuild.yml@master + with: + aws_region: ${{ needs.set_vars.outputs.aws_region }} + aws_account_id: ${{ needs.set_vars.outputs.aws_account_id }} + aws_role_assume_name: ${{ needs.set_vars.outputs.aws_role_assume_name }} + codebuild_project_name: ${{ needs.set_vars.outputs.codebuild_project_name }} + culiops_branch: ${{ needs.set_vars.outputs.culiops_branch }} + ecs_cluster_name: ${{ needs.set_vars.outputs.ecs_cluster_name }} + ecs_service_name: ${{ needs.set_vars.outputs.ecs_service_name }} + app_repo_name: ${{ needs.set_vars.outputs.app_repo_name }} + app_branch: ${{ needs.set_vars.outputs.app_branch }} \ No newline at end of file