-
Notifications
You must be signed in to change notification settings - Fork 0
98 lines (97 loc) · 3.66 KB
/
deploy.yml
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
---
name: Deploy Sanitas
on: # yamllint disable-line rule:truthy
push:
branches:
- staging
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
jobs:
backend-deploy:
environment:
name: build
name: Backend Deployment
runs-on: ubuntu-latest
outputs:
backend_url: ${{ steps.get_url_step.outputs.url }}
secure_url: ${{ steps.get_secure_url.outputs.url }}
cognito_user_pool_id: ${{ steps.get_pool_id.outputs.id }}
cognito_pool_client_id: ${{ steps.get_client_id.outputs.id }}
defaults:
run:
shell: nix develop .#cicdBackend --command bash {0}
working-directory: sanitas_backend
steps:
- uses: actions/checkout@v4
with:
ref: staging
- uses: DeterminateSystems/nix-installer-action@main
- name: Configure AWS Credentials Action for GitHub Actions
uses: aws-actions/[email protected]
with:
audience: sts.amazonaws.com
aws-region: us-east-2
role-to-assume: ${{ secrets.BACKEND_DEPLOY_AWS_ROLE }}
- name: Building Backend
run: sam build --use-container
- name: Deploying Backend
# yamllint disable rule:line-length
run: sam deploy --no-confirm-changeset --no-fail-on-empty-changeset
--parameter-overrides PostgresURL=${{ secrets.DB_URL }}
- name: Saving Backend URL
id: get_url_step
run: echo url=$(sam list stack-outputs --stack-name sanitas-backend
--output json | jq .[1].OutputValue | sed -e 's/^\"//' -e
's/\/\"$//') >> $GITHUB_OUTPUT
- name: Saving Secured Backend URL
id: get_secure_url
run: echo url=$(sam list stack-outputs --stack-name sanitas-backend
--output json | jq .[0].OutputValue | sed -e 's/^\"//' -e
's/\/\"$//') >> $GITHUB_OUTPUT
- name: Saving Cognito Pool ID
id: get_pool_id
run: echo id=$(sam list resources --stack-name sanitas-backend
--output json | jq '.[] | select(.LogicalResourceId == "CognitoUserPool")
| .PhysicalResourceId' | sed -e 's/^\"//' -e 's/\"$//') >>
$GITHUB_OUTPUT
- name: Saving Cognito Client ID
id: get_client_id
run: echo id=$(sam list resources --stack-name sanitas-backend
--output json | jq '.[] | select(.LogicalResourceId == "CognitoUserPoolClient")
| .PhysicalResourceId' | sed -e 's/^\"//' -e 's/\"$//') >>
$GITHUB_OUTPUT
# yamllint enable rule:line-length
frontend-deploy:
name: Frontend Deployment
needs: backend-deploy
environment:
name: build
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
defaults:
run:
shell: nix develop .#cicdFrontend --command bash {0}
working-directory: sanitas_frontend
steps:
- uses: actions/checkout@v4
with:
ref: staging
- uses: DeterminateSystems/nix-installer-action@main
- uses: actions/configure-pages@v4
- name: Building frontend
# yamllint disable rule:line-length
run: yarn && BACKEND_URL=${{ needs.backend-deploy.outputs.backend_url
}} COGNITO_POOL_ID=${{ needs.backend-deploy.outputs.cognito_user_pool_id
}} COGNITO_CLIENT_ID=${{ needs.backend-deploy.outputs.cognito_pool_client_id
}} PROTECTED_URL=${{ needs.backend-deploy.outputs.secure_url
}} yarn build --base=/Sanitas/
# yamllint enable rule:line-length
- name: Uploading to Github pages
uses: actions/upload-pages-artifact@v3
with:
path: ./sanitas_frontend/dist
- uses: actions/deploy-pages@v4
id: deployment