Deploy Issuer Node Backend to Demo AWS Environment #125
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy Issuer Node Backend to Demo AWS Environment | |
| on: | |
| workflow_run: | |
| workflows: ["Checks"] | |
| branches: ["main", "develop"] | |
| types: | |
| - completed | |
| env: | |
| AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }} | |
| AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} | |
| AWS_ACCOUNT_ID_BSH: ${{ secrets.AWS_ACCOUNT_ID_BSH }} | |
| jobs: | |
| build-backend: | |
| environment: | |
| name: ${{ github.event.workflow_run.head_branch }} | |
| name: build and push latest image to AWS 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@v4 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| - uses: actions/setup-go@v3 | |
| with: | |
| go-version-file: go.mod | |
| - 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: Print branch | |
| run: git branch --show-current | |
| - name: Create .env-issuer | |
| run: | | |
| touch .env-issuer | |
| - 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: ${{ vars.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 | |
| - name: Configure AWS credentials Billions SH | |
| uses: aws-actions/configure-aws-credentials@v1-node16 | |
| if: github.event.workflow_run.head_branch == 'main' | |
| with: | |
| aws-region: ${{ env.AWS_DEFAULT_REGION }} | |
| role-to-assume: arn:aws:iam::${{ env.AWS_ACCOUNT_ID_BSH }}:role/BillionsActionsRole | |
| role-session-name: GitHubActionsSession | |
| - name: Login to Amazon ECR Billions SH | |
| uses: aws-actions/amazon-ecr-login@v1 | |
| if: github.event.workflow_run.head_branch == 'main' | |
| id: login-ecr-bsh | |
| - name: Tag and push image Billions SH | |
| if: github.event.workflow_run.head_branch == 'main' | |
| env: | |
| ECR_REGISTRY: ${{ steps.login-ecr-bsh.outputs.registry }} | |
| ECR_REPOSITORY: ${{ vars.ECR_REPOSITORY_BSH }} | |
| 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 |