From c537604d319ea53e8e75fac11465bb1dbbaff12a Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Fri, 22 Mar 2024 11:26:17 -0300 Subject: [PATCH 1/3] chore: add test deploy backend --- .github/workflows/test_deploy_backend.yml | 66 +++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 .github/workflows/test_deploy_backend.yml diff --git a/.github/workflows/test_deploy_backend.yml b/.github/workflows/test_deploy_backend.yml new file mode 100644 index 000000000..07a99835b --- /dev/null +++ b/.github/workflows/test_deploy_backend.yml @@ -0,0 +1,66 @@ +name: Deploy Issuer Node Backend to Testing AWS Environment + +on: + workflow_run: + workflows: ["Checks"] + branches: ["develop"] + types: + - completed + +env: + AWS_ACCOUNT_ID: ${{ secrets.TEST_AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + ECR_REPOSITORY: issuer_node_backend_testing + +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- + + - 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 From f323b5c4ae088c600ead252d9e60a3a89f53a6ab Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Fri, 22 Mar 2024 12:02:50 -0300 Subject: [PATCH 2/3] chore: update github action --- .github/workflows/test_deploy_backend.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/test_deploy_backend.yml b/.github/workflows/test_deploy_backend.yml index 07a99835b..32e0a82e5 100644 --- a/.github/workflows/test_deploy_backend.yml +++ b/.github/workflows/test_deploy_backend.yml @@ -36,6 +36,10 @@ jobs: restore-keys: | ${{ runner.os }}-go- + - name: Create .env-api + run: | + touch .env-api + - run: make build/docker - name: Configure AWS credentials From c311b7c6071f3e6ded7e5dda5af0f20491cabb77 Mon Sep 17 00:00:00 2001 From: Martin Saporiti Date: Mon, 25 Mar 2024 08:23:18 -0300 Subject: [PATCH 3/3] chore: add deploy ui to testing env --- .github/workflows/test_deploy_ui.yml | 61 ++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 .github/workflows/test_deploy_ui.yml diff --git a/.github/workflows/test_deploy_ui.yml b/.github/workflows/test_deploy_ui.yml new file mode 100644 index 000000000..3296559a4 --- /dev/null +++ b/.github/workflows/test_deploy_ui.yml @@ -0,0 +1,61 @@ +name: Deploy Issuer Node UI to Testing AWS Environment + +on: + push: + branches: + - develop + +env: + AWS_ACCOUNT_ID: ${{ secrets.TEST_AWS_ACCOUNT_ID }} + AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} + ECR_REPOSITORY: issuer_node_ui_testing + +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