From 95794998350ea937da6a1f68a94b4826773fd677 Mon Sep 17 00:00:00 2001 From: Phil Corbett <1835431+Phuurl@users.noreply.github.com> Date: Sun, 24 Apr 2022 21:06:33 +0100 Subject: [PATCH] Passes CloudFront domain to function when `NoDomain` is set (#10) * Passes CloudFront domain to function When NoDomain is set * Adds repo name tag and JPEG upload to PR deploy --- .github/workflows/checks.yml | 5 +++-- template.yaml | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 201281b..6ca500f 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -68,7 +68,7 @@ jobs: sed -i -e "s|s3_bucket = \"{}\"|s3_bucket = \"${SAM_BUCKET}\"|g" samconfig.toml sed -i -e "s|s3_prefix = \"{}\"|s3_prefix = \"GITHUB-Phuurl-img-site-PR-${PRNUM}\"|g" samconfig.toml sed -i -e "s|parameter_overrides = \"{}\"|parameter_overrides = \"UploadBucketName=\\\\\"github-phuurl-img-site-pr-upload-${PRNUM}\\\\\" EmailNotificationEnabled=\\\\\"false\\\\\" NotificationEmail=\\\\\"x\\\\\" SiteName=\\\\\"GITHUB-Phuurl-img-site-PR-${PRNUM}\\\\\" NoDomain=\\\\\"true\\\\\" Domain=\\\\\"x\\\\\" CertArn=\\\\\"x\\\\\" CloudFrontRedirectFunctionName=\\\\\"GITHUB_Phuurl_img_site_PR_${PRNUM}_index_redirect_func\\\\\" CloudFrontCachePolicyName=\\\\\"GITHUB-Phuurl-img-site-PR-${PRNUM}-cache-policy\\\\\" CreateUploadIamUser=\\\\\"false\\\\\"\"|g" samconfig.toml - sed -i -e "s|tags = \"{}\"|tags = \"project=\\\\\"github\\\\\" pr=\\\\\"${PRNUM}\\\\\"\"|g" samconfig.toml + sed -i -e "s|tags = \"{}\"|tags = \"project=\\\\\"github\\\\\" repo=\\\\\"img-site\\\\\" pr=\\\\\"${PRNUM}\\\\\"\"|g" samconfig.toml cat samconfig.toml env: PRNUM: ${{ github.event.number }} @@ -89,9 +89,10 @@ jobs: aws s3 cp robots.txt s3://${HostingBucketName}/ env: PRNUM: ${{ github.event.number }} - - name: Upload input image + - name: Upload input images run: | UploadBucketName=$(aws cloudformation describe-stacks --stack-name "GITHUB-Phuurl-img-site-PR-${PRNUM}" --query "Stacks[0].Outputs[?OutputKey=='UploadBucketName'].OutputValue" --output text --region eu-west-1) aws s3 cp ingest-fn/.test-resources/500x500.png s3://${UploadBucketName}/ + aws s3 cp ingest-fn/.test-resources/500x500.jpg s3://${UploadBucketName}/ env: PRNUM: ${{ github.event.number }} diff --git a/template.yaml b/template.yaml index 6bd4694..839f982 100644 --- a/template.yaml +++ b/template.yaml @@ -310,7 +310,11 @@ Resources: Variables: HOSTING_BUCKET: !Ref HostingBucket SITE_NAME: !Ref SiteName - DOMAIN: !Ref Domain + DOMAIN: + !If + - CloudFrontNoDomain + - !GetAtt CloudFrontDistribution.DomainName + - !Ref Domain SNS_TOPIC_ARN: !Ref NotificationTopic Metadata: BuildMethod: makefile