This repository was archived by the owner on Jun 2, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
75 lines (55 loc) · 2.23 KB
/
Copy pathcd.yml
File metadata and controls
75 lines (55 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
name: Continuous Delivery
on:
push:
branches:
- main
- gsa-ai-dev
concurrency: # queue up this workflow for a specific branch
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: false
permissions:
id-token: write
pull-requests: write
contents: read
jobs:
build:
name: Build
uses: ./.github/workflows/build.yml
deploy:
name: Deploy
environment:
name: ${{ github.ref == 'refs/heads/gsa-ai-dev' && 'gsa-ai-dev' || 'gsa-dev' }}
runs-on: ubuntu-latest
needs:
- build
steps:
- uses: actions/checkout@v4
- uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_FOR_DEPLOY }}
aws-region: us-east-1
- uses: hashicorp/setup-terraform@v3
- name: Restore Backend Artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.BACKEND_ARTIFACT_NAME }}
path: backend/dist/
- name: Restore Frontend Artifact
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.FRONTEND_ARTIFACT_NAME }}
path: ui/dist/
- working-directory: ./iac/
run: terraform init -backend-config="bucket=document-extractor-${{ vars.ENVIRONMENT }}-terraform-state" -backend-config="key=terraform_state_${{ vars.ENVIRONMENT }}.tfstate"
- working-directory: ./iac/
run: terraform apply -auto-approve -var 'environment=${{ vars.ENVIRONMENT }}' -var 'textract_form_adapters_env_var_mapping=${{ secrets.TEXTRACT_FORM_ADAPTERS_ENV_VARS_MAPPING }}'
- name: Extract Terraform Output
working-directory: ./iac/
id: terraformOutput
run: |
distribution_id=$(terraform output -raw distribution_id)
echo "distribution_id=$distribution_id" >> $GITHUB_OUTPUT
- name: Invalidate Cloudfront Distribution
run: |
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id ${{ steps.terraformOutput.outputs.distribution_id }} --paths "/*" --query 'Invalidation.Id' --output text)
aws cloudfront wait invalidation-completed --distribution-id ${{ steps.terraformOutput.outputs.distribution_id }} --id $INVALIDATION_ID