-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaskFile.yml
82 lines (70 loc) · 3.02 KB
/
TaskFile.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
version: "3"
env:
AWS_PROFILE:
sh: echo $AWS_PROFILE
CLOUDFRONT_URL:
sh: echo ${CLOUDFRONT_URL:-https://dummy.example.com/}
tasks:
default:
desc: task -> show commands
cmds:
- task -l --sort none
update-docs-local:
desc: task update-docs-local -> generate dbt docs locally
dir: dbt-sample/dbt_project
cmds:
- uv run dbt docs generate
upload-docs-for-hosted-site:
desc: task update-docs-for-hosted-site -> generate dbt docs for hosted site
dir: dbt-sample/dbt_project
requires:
vars:
- AWS_PROFILE
cmds:
- test -f ../../infrastructure/docs-stack-outputs.json || { echo "Error ../../infrastructure/docs-stack-outputs.json file not found"; exit 1; }
- aws s3 cp ./target/index.html s3://$(jq -r '.DocsStack.DocsBucketName' ../../infrastructure/docs-stack-outputs.json) --profile={{ .AWS_PROFILE }}
- aws s3 cp ./target/manifest.json s3://$(jq -r '.DocsStack.DocsBucketName' ../../infrastructure/docs-stack-outputs.json) --profile={{ .AWS_PROFILE }}
- aws s3 cp ./target/catalog.json s3://$(jq -r '.DocsStack.DocsBucketName' ../../infrastructure/docs-stack-outputs.json) --profile={{ .AWS_PROFILE }}
# dbtのドキュメントに画像ファイル等がある場合は以下のコメントを解除
# - aws s3 cp ./target/assets s3://$(jq -r '.DocsStack.DocsBucketName' ../../infrastructure/docs-stack-outputs.json)/assets --profile={{ .AWS_PROFILE }} --recursive
# ドキュメントサイトのキャッシュを無効化(即時更新のために入れているが、更新が即時反映されなくても良い場合は不要)
- aws cloudfront create-invalidation --distribution-id $(jq -r '.DocsStack.DistributionId' ../../infrastructure/docs-stack-outputs.json) --paths "/*" --profile {{ .AWS_PROFILE }}
update-dbt-docs:
desc: task update-dbt-docs -> update dbt docs
cmds:
- task: update-docs-local
- echo "Updated dbt local docs"
- task: upload-docs-for-hosted-site
- echo "Updated hosted docs"
deploy-cognito:
desc: Deploy Cognito stack first and save output (JSON file is saved to a gitignored location)
dir: infrastructure
cmds:
- npx cdk deploy -O lambda/auth/cognito-outputs.json CognitoStack
deploy-docs:
desc: Deploy CloudFront & Lambda@edge (DocsStack) using saved Cognito outputs
dir: infrastructure
cmds:
- CLOUDFRONT_URL=$CLOUDFRONT_URL npx cdk deploy -O docs-stack-outputs.json DocsStack
deploy-all:
desc: Deploy all stacks in order; Cognito, Docs
cmds:
- task: deploy-cognito
- task: deploy-docs
- echo "Deployed all stacks successfully"
destroy-cognito:
desc: Destroy Cognito stack
dir: infrastructure
cmds:
- npx cdk destroy CognitoStack
destroy-docs:
desc: Destroy Docs stack
dir: infrastructure
cmds:
- npx cdk destroy DocsStack
destroy-all:
desc: Destroy all stacks
cmds:
- task: destroy-cognito
- task: destroy-docs
- echo "Destroyed all stacks successfully"