diff --git a/.github/workflows/dev_deploy_new_account.yml b/.github/workflows/deploy_new_account.yml similarity index 93% rename from .github/workflows/dev_deploy_new_account.yml rename to .github/workflows/deploy_new_account.yml index 32b54c7..29fbf8f 100644 --- a/.github/workflows/dev_deploy_new_account.yml +++ b/.github/workflows/deploy_new_account.yml @@ -1,16 +1,14 @@ -name: Deploy verifier backend to Development AWS Environment new account +name: Deploy verifier backend to AWS Environment new account on: workflow_run: workflows: ["Checks"] - branches: ["develop"] + branches: ["develop", "main"] types: - completed env: - AWS_ACCOUNT_ID: ${{ secrets.DEV_AWS_ACCOUNT_ID_NEW }} AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} - ENVIRONMENT: dev ECR_REPOSITORY: verifier_backend POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" POLYGON_AMOY_CONTRACT_ADDRESS: "0x8c99F13dc5083b1E4c16f269735EaD4cFbc4970d" @@ -18,13 +16,15 @@ env: jobs: build-backend: + environment: + name: ${{ github.ref_name }} + name: Build and push latest image to AWS permissions: id-token: write contents: write if: ${{ github.event.workflow_run.conclusion == 'success' }} runs-on: ubuntu-latest - environment: dev steps: - name: Checkout code @@ -59,6 +59,8 @@ jobs: - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v1-node16 + env: + AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID_NEW }} with: aws-region: ${{ env.AWS_DEFAULT_REGION }} role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID }}:role/PolygonIDActionsRole diff --git a/.github/workflows/prod_deploy_new_account.yml b/.github/workflows/prod_deploy_new_account.yml deleted file mode 100644 index c8e0c3f..0000000 --- a/.github/workflows/prod_deploy_new_account.yml +++ /dev/null @@ -1,85 +0,0 @@ -name: Deploy verifier backend to Production AWS Environment new account - -on: - workflow_run: - workflows: ["Checks"] - branches: ["develop"] - types: - - completed - -env: - AWS_ACCOUNT_ID: ${{ secrets.PROD_AWS_ACCOUNT_ID_NEW }} - AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} - ENVIRONMENT: dev - ECR_REPOSITORY: verifier_backend - POLYGON_MUMBAI_CONTRACT_ADDRESS: "0x134B1BE34911E39A8397ec6289782989729807a4" - POLYGON_AMOY_CONTRACT_ADDRESS: "0x8c99F13dc5083b1E4c16f269735EaD4cFbc4970d" - POLYGON_MAIN_CONTRACT_ADDRESS: "0x624ce98D2d27b20b8f8d521723Df8fC4db71D79D" - -jobs: - build-backend: - name: Build and push latest image to AWS - permissions: - id-token: write - contents: write - if: ${{ github.event.workflow_run.conclusion == 'success' }} - runs-on: ubuntu-latest - environment: dev - - 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: Build file with supported networks - run: | - echo -e "polygon:" > resolvers_settings.yaml - echo -e " amoy:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_AMOY_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_AMOY_NODE_URL }}" >> resolvers_settings.yaml - echo -e " mumbai:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MUMBAI_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_NODE_URL }}" >> resolvers_settings.yaml - echo -e " main:" >> resolvers_settings.yaml - echo -e " contractAddress: ${{ env.POLYGON_MAIN_CONTRACT_ADDRESS }}" >> resolvers_settings.yaml - echo -e " networkURL: ${{ secrets.POLYGON_MAINET_NODE_URL }}" >> resolvers_settings.yaml - cat resolvers_settings.yaml - - 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 polygonid/verifier-backend:${{ 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/verifier-backend:${{ env.IMAGE_TAG }} ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest - docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest