Skip to content

Commit

Permalink
Create deploy_backend_v2.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
martinsaporiti authored Aug 5, 2024
1 parent 0367804 commit 5a46e31
Showing 1 changed file with 72 additions and 0 deletions.
72 changes: 72 additions & 0 deletions .github/workflows/deploy_backend_v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: Deploy Issuer Node Backend V2 AWS Environment

on:
workflow_run:
workflows: ["Checks"]
branches: ["develop-v2"]
types:
- completed

env:
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}

jobs:
build-backend:
environment:
name: ${{ github.event.workflow_run.head_branch }}
name: Build and push issuer node v2 backend 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@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
env:
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
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

0 comments on commit 5a46e31

Please sign in to comment.