fix: use .env or system env to manage backend test db connection (#114) #98
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 to Sandbox | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| id-token: write | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Configure AWS Credentials | |
| uses: aws-actions/configure-aws-credentials@main | |
| with: | |
| role-to-assume: arn:aws-us-gov:iam::250902968334:role/GithubActionsDeployRole | |
| aws-region: us-gov-west-1 | |
| - name: Login to Amazon ECR | |
| id: login-ecr | |
| uses: aws-actions/amazon-ecr-login@v2 | |
| - name: Build, tag, push migration image to Amazon ECR | |
| working-directory: flyway | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| REPOSITORY: ndh-migrations | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . | |
| docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG | |
| docker tag $REGISTRY/$REPOSITORY:$IMAGE_TAG $REGISTRY/$REPOSITORY | |
| docker push $REGISTRY/$REPOSITORY:latest | |
| echo "TF_VAR_migration_image=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> "$GITHUB_ENV" | |
| - name: Build, tag, and push docker image to Amazon ECR | |
| working-directory: backend | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| REPOSITORY: ndh | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| docker build -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . | |
| docker push $REGISTRY/$REPOSITORY:$IMAGE_TAG | |
| docker tag $REGISTRY/$REPOSITORY:$IMAGE_TAG $REGISTRY/$REPOSITORY | |
| docker push $REGISTRY/$REPOSITORY:latest | |
| echo "TF_VAR_container_image=$REGISTRY/$REPOSITORY:$IMAGE_TAG" >> "$GITHUB_ENV" | |
| - name: Configure Terraform | |
| uses: hashicorp/setup-terraform@v3 | |
| - name: Update Infrastructure, Deploy API | |
| working-directory: infrastructure | |
| env: | |
| REGISTRY: ${{ steps.login-ecr.outputs.registry }} | |
| REPOSITORY: ndh | |
| IMAGE_TAG: ${{ github.sha }} | |
| run: | | |
| terraform init | |
| terraform apply -auto-approve | |
| echo "FRONTEND_S3_BUCKET=$(terraform output --raw frontend_s3_bucket)" >> "$GITHUB_ENV" | |
| echo "VITE_API_BASE_URL=http://$(terraform output --raw alb_dns_name)" >> "$GITHUB_ENV" | |
| - name: Setup NodeJS | |
| uses: actions/setup-node@v4 | |
| - name: Deploy Frontend | |
| working-directory: frontend | |
| run: | | |
| npm install | |
| npm run build | |
| aws s3 cp ./dist s3://$FRONTEND_S3_BUCKET/ --recursive |