Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 23 additions & 10 deletions .github/workflows/deploy-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@

name: Deploy to dev (AWS S3)
env:
AWS_S3_BUCKET_NAME : ${{ vars.AWS_S3_BUCKET_NAME }}
AWS_REGION_NAME : ${{ vars.AWS_REGION_NAME }}
AWS_S3_BUCKET_NAME : rpp-landing
AWS_REGION_NAME : eu-central-1
CLOUDFRONT_ID: EILUB1IE9EON0
BUILD_DIR : "build/"
DOCS_BASE_URL: "/"
DOCS_BASE_URL: "/docs/"

on:
push:
Expand All @@ -32,7 +33,7 @@ permissions:
contents: read

jobs:
empty-s3-bucket:
clean-docs-folder:
runs-on: ubuntu-latest
environment: development
steps:
Expand All @@ -42,12 +43,18 @@ jobs:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
aws-region: ${{ env.AWS_REGION_NAME }}

- name: Empty AWS S3 bucket
run: aws s3 rm s3://${{ env.AWS_S3_BUCKET_NAME }} --recursive
- name: Clear docs folder in S3 bucket
run: |
if aws s3 ls "s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/" 2>/dev/null; then
echo "docs/ folder exists, removing it..."
aws s3 rm s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/ --recursive
else
echo "docs/ folder does not exist, nothing to clean."
fi

deploy:
runs-on: ubuntu-latest
needs: [empty-s3-bucket]
needs: [clean-docs-folder]
environment: development
steps:
- name: Checkout repository
Expand Down Expand Up @@ -76,7 +83,13 @@ jobs:
aws-region: ${{ env.AWS_REGION_NAME }}

- name: Deploy to AWS S3
run: aws s3 sync ./${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET_NAME }}
run: aws s3 sync ./${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/

- name: Clearing CloudFront cache
run: aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_ID }} --paths "/docs/*"

- name: Invalidate AWS CloudFront cache
run: aws cloudfront create-invalidation --distribution-id ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
- name: Trigger Amplify redeploy
run: |
aws amplify start-deployment \
--app-id ${{ secrets.AWS_AMPLIFY_APP_ID }} \
--branch-name staging