Skip to content

Commit 41aa298

Browse files
authored
Merge branch 'main' into dsingh14/fix-caching
2 parents 194a486 + 1b1375a commit 41aa298

25 files changed

+778
-340
lines changed

.github/workflows/deploy-dev.yml

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ jobs:
5858
env:
5959
HUSKY: "0"
6060
VITE_RUN_ENVIRONMENT: dev
61-
- name: Publish to Cloudflare
62-
uses: cloudflare/pages-action@v1
63-
with:
64-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
65-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
66-
projectName: management-ui-dev
67-
directory: dist_ui/
68-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
69-
branch: main
7061

7162
test-dev:
7263
runs-on: ubuntu-latest

.github/workflows/deploy-prod.yml

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,6 @@ jobs:
5858
env:
5959
HUSKY: "0"
6060
VITE_RUN_ENVIRONMENT: dev
61-
- name: Publish to Cloudflare
62-
uses: cloudflare/pages-action@v1
63-
with:
64-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
65-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
66-
projectName: management-ui-dev
67-
directory: dist_ui/
68-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
69-
branch: main
7061

7162
test-dev:
7263
runs-on: ubuntu-latest
@@ -132,15 +123,6 @@ jobs:
132123
env:
133124
HUSKY: "0"
134125
VITE_RUN_ENVIRONMENT: prod
135-
- name: Publish to Cloudflare
136-
uses: cloudflare/pages-action@v1
137-
with:
138-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
139-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
140-
projectName: management-ui-prod
141-
directory: dist_ui/
142-
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
143-
branch: main
144126

145127
health-check-prod:
146128
runs-on: ubuntu-latest

Makefile

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ set_application_name = ParameterKey=ApplicationFriendlyName,ParameterValue
44

55
prod_aws_account = 298118738376
66
dev_aws_account = 427040638965
7+
current_aws_account := $(shell aws sts get-caller-identity --query Account --output text)
78

89
src_directory_root = src/
10+
dist_ui_directory_root = dist_ui/
911
integration_test_directory_root = tests/live_integration/
1012

1113
# CHANGE ME (as needed)
@@ -24,22 +26,23 @@ common_params = --no-confirm-changeset \
2426
--s3-prefix $(application_key) \
2527
--resolve-s3
2628

29+
s3_bucket_prefix = "$(current_aws_account)-$(region)-$(application_key)"
30+
ui_s3_bucket = "$(s3_bucket_prefix)-ui"
31+
2732
GIT_HASH := $(shell git rev-parse --short HEAD)
2833

29-
.PHONY: build clean
34+
.PHONY: clean
3035

3136
check_account_prod:
32-
@aws_account_id=$$(aws sts get-caller-identity --query Account --output text); \
33-
if [ "$$aws_account_id" != "$(prod_aws_account)" ]; then \
34-
echo "Error: running in incorrect account $$aws_account_id, expected account ID $(prod_aws_account)"; \
35-
exit 1; \
36-
fi
37+
ifneq ($(current_aws_account),$(prod_aws_account))
38+
$(error Error: running in account $(current_aws_account), expected account ID $(prod_aws_account))
39+
endif
40+
3741
check_account_dev:
38-
@aws_account_id=$$(aws sts get-caller-identity --query Account --output text); \
39-
if [ "$$aws_account_id" != "$(dev_aws_account)" ]; then \
40-
echo "Error: running in incorrect account $$aws_account_id, expected account ID $(dev_aws_account)"; \
41-
exit 1; \
42-
fi
42+
ifneq ($(current_aws_account),$(dev_aws_account))
43+
$(error Error: running in account $(current_aws_account), expected account ID $(dev_aws_account))
44+
endif
45+
4346

4447
clean:
4548
rm -rf .aws-sam
@@ -61,11 +64,26 @@ local:
6164
VITE_BUILD_HASH=$(GIT_HASH) yarn run dev
6265

6366
deploy_prod: check_account_prod build
64-
aws sts get-caller-identity --query Account --output text
65-
sam deploy $(common_params) --parameter-overrides $(run_env)=prod $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)"
67+
@echo "Deploying CloudFormation stack..."
68+
sam deploy $(common_params) --parameter-overrides $(run_env)=prod $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)"
69+
@echo "Syncing S3 bucket..."
70+
aws s3 sync $(dist_ui_directory_root) s3://$(ui_s3_bucket)/ --delete
71+
make invalidate_cloudfront
6672

6773
deploy_dev: check_account_dev build
68-
sam deploy $(common_params) --parameter-overrides $(run_env)=dev $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)"
74+
@echo "Deploying CloudFormation stack..."
75+
sam deploy $(common_params) --parameter-overrides $(run_env)=dev $(set_application_prefix)=$(application_key) $(set_application_name)="$(application_name)" S3BucketPrefix="$(s3_bucket_prefix)"
76+
@echo "Syncing S3 bucket..."
77+
aws s3 sync $(dist_ui_directory_root) s3://$(ui_s3_bucket)/ --delete
78+
make invalidate_cloudfront
79+
80+
invalidate_cloudfront:
81+
@echo "Creating CloudFront invalidation..."
82+
$(eval DISTRIBUTION_ID := $(shell aws cloudformation describe-stacks --stack-name $(application_key) --query "Stacks[0].Outputs[?OutputKey=='CloudfrontDistributionId'].OutputValue" --output text))
83+
$(eval INVALIDATION_ID := $(shell aws cloudfront create-invalidation --distribution-id $(DISTRIBUTION_ID) --paths "/*" --query 'Invalidation.Id' --output text --no-cli-page))
84+
@echo "Waiting on job $(INVALIDATION_ID)..."
85+
aws cloudfront wait invalidation-completed --distribution-id $(DISTRIBUTION_ID) --id $(INVALIDATION_ID)
86+
@echo "CloudFront invalidation completed!"
6987

7088
install:
7189
yarn -D
@@ -86,7 +104,7 @@ test_e2e: install
86104
yarn test:e2e
87105

88106
dev_health_check:
89-
curl -f https://$(application_key).aws.qa.acmuiuc.org/api/v1/healthz && curl -f https://manage.qa.acmuiuc.org
107+
curl -f https://core.aws.qa.acmuiuc.org/api/v1/healthz && curl -f https://core.aws.qa.acmuiuc.org/
90108

91109
prod_health_check:
92-
curl -f https://$(application_key).aws.acmuiuc.org/api/v1/healthz && curl -f https://manage.acm.illinois.edu
110+
curl -f https://core.acm.illinois.edu/api/v1/healthz && curl -f https://core.acm.illinois.edu

0 commit comments

Comments
 (0)