From 83481a66497c79ee1842412e6e40c231c000e470 Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Fri, 14 Jun 2024 12:14:21 -0300 Subject: [PATCH 1/2] chore: add deploy to demo --- .github/workflows/demo_deploy_backend.yml | 70 +++++++++++++++++++++++ .github/workflows/demo_deploy_ui.yml | 61 ++++++++++++++++++++ 2 files changed, 131 insertions(+) create mode 100644 .github/workflows/demo_deploy_backend.yml create mode 100644 .github/workflows/demo_deploy_ui.yml diff --git a/.github/workflows/demo_deploy_backend.yml b/.github/workflows/demo_deploy_backend.yml new file mode 100644 index 000000000..266c8fe43 --- /dev/null +++ b/.github/workflows/demo_deploy_backend.yml @@ -0,0 +1,70 @@ +name: Deploy Issuer Node Backend to Testing AWS Environment + +on: + workflow_run: + workflows: ["Checks"] + branches: ["main"] + types: + - completed + +env: + AWS_ACCOUNT_ID: ${{ secrets.TEST_AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + ECR_REPOSITORY: issuer_node_backend_demo + +jobs: + build-backend: + name: Build and push latest image to AWS Testing Environment + permissions: + id-token: write + contents: write + if: ${{ github.event.workflow_run.conclusion == 'success' }} + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + with: + go-version: "1.20" + - uses: actions/cache@v3 + with: + path: | + ~/go/pkg/mod + ~/.cache/go-build + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Create .env-api + run: | + touch .env-api + + - run: make build/docker + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1-node16 + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole + role-session-name: GitHubActionsSession + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + id: login-ecr + + - name: Get version + run: echo "::set-output name=VERSION::$(git rev-parse --short HEAD)" + id: version + + - name: Tag and push image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + run: | + docker tag issuer/api:${{ env.IMAGE_TAG }} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + + docker tag issuer/api:${{ env.IMAGE_TAG }} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ No newline at end of file diff --git a/.github/workflows/demo_deploy_ui.yml b/.github/workflows/demo_deploy_ui.yml new file mode 100644 index 000000000..72ae3a331 --- /dev/null +++ b/.github/workflows/demo_deploy_ui.yml @@ -0,0 +1,61 @@ +name: Deploy Issuer Node UI to Testing AWS Environment + +on: + push: + branches: + - main + +env: + AWS_ACCOUNT_ID: ${{ secrets.TEST_AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + ECR_REPOSITORY: issuer_node_ui_demo + +jobs: + deploy: + name: Build and Deploy UI to Testing AWS Environment + runs-on: ubuntu-latest + permissions: + id-token: write + contents: write + steps: + - name: Checkout + uses: actions/checkout@v2 + + - uses: actions/setup-node@v2 + with: + node-version: 16 + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1-node16 + with: + aws-region: ${{ env.AWS_DEFAULT_REGION }} + role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole + role-session-name: GitHubActionsSession + + - name: Login to Amazon ECR + uses: aws-actions/amazon-ecr-login@v1 + id: login-ecr + + - name: Get version + run: echo "::set-output name=VERSION::$(git rev-parse --short HEAD)" + id: version + + - name: build ui docker image + working-directory: ./ui + env: + IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + run: | + docker build -t polygonid/issuernode_ui:${{ env.IMAGE_TAG }} . + + + - name: Tag and push image + env: + ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} + ECR_REPOSITORY: ${{ env.ECR_REPOSITORY }} + IMAGE_TAG: ${{ steps.version.outputs.VERSION }} + run: | + docker tag polygonid/issuernode_ui:${{ env.IMAGE_TAG }} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.IMAGE_TAG }} + + docker tag polygonid/issuernode_ui:${{ env.IMAGE_TAG }} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest + docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \ No newline at end of file From 45f39f240d073835fcb5ad22d7ee2c18eb5d3e29 Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Thu, 20 Jun 2024 13:25:29 -0300 Subject: [PATCH 2/2] fix: naming --- .github/workflows/demo_deploy_backend.yml | 4 ++-- .github/workflows/demo_deploy_ui.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/demo_deploy_backend.yml b/.github/workflows/demo_deploy_backend.yml index 266c8fe43..991158c71 100644 --- a/.github/workflows/demo_deploy_backend.yml +++ b/.github/workflows/demo_deploy_backend.yml @@ -1,4 +1,4 @@ -name: Deploy Issuer Node Backend to Testing AWS Environment +name: Deploy Issuer Node Backend to Demo AWS Environment on: workflow_run: @@ -14,7 +14,7 @@ env: jobs: build-backend: - name: Build and push latest image to AWS Testing Environment + name: Build and push latest image to AWS Demo Environment permissions: id-token: write contents: write diff --git a/.github/workflows/demo_deploy_ui.yml b/.github/workflows/demo_deploy_ui.yml index 72ae3a331..121f549ed 100644 --- a/.github/workflows/demo_deploy_ui.yml +++ b/.github/workflows/demo_deploy_ui.yml @@ -1,4 +1,4 @@ -name: Deploy Issuer Node UI to Testing AWS Environment +name: Deploy Issuer Node UI to Demo AWS Environment on: push: @@ -12,7 +12,7 @@ env: jobs: deploy: - name: Build and Deploy UI to Testing AWS Environment + name: Build and Deploy UI to Demo AWS Environment runs-on: ubuntu-latest permissions: id-token: write