1313
1414name : Deploy to dev (AWS S3)
1515env :
16- AWS_S3_BUCKET_NAME : ${{ vars.AWS_S3_BUCKET_NAME }}
17- AWS_REGION_NAME : ${{ vars.AWS_REGION_NAME }}
16+ AWS_S3_BUCKET_NAME : rpp-landing
17+ AWS_REGION_NAME : eu-central-1
18+ CLOUDFRONT_ID : EILUB1IE9EON0
1819 BUILD_DIR : " build/"
19- DOCS_BASE_URL : " /"
20+ DOCS_BASE_URL : " /docs/ "
2021
2122on :
2223 push :
@@ -32,7 +33,7 @@ permissions:
3233 contents : read
3334
3435jobs :
35- empty-s3-bucket :
36+ clean-docs-folder :
3637 runs-on : ubuntu-latest
3738 environment : development
3839 steps :
@@ -42,12 +43,18 @@ jobs:
4243 role-to-assume : ${{ secrets.AWS_ROLE_ARN }}
4344 aws-region : ${{ env.AWS_REGION_NAME }}
4445
45- - name : Empty AWS S3 bucket
46- run : aws s3 rm s3://${{ env.AWS_S3_BUCKET_NAME }} --recursive
46+ - name : Clear docs folder in S3 bucket
47+ run : |
48+ if aws s3 ls "s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/" 2>/dev/null; then
49+ echo "docs/ folder exists, removing it..."
50+ aws s3 rm s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/ --recursive
51+ else
52+ echo "docs/ folder does not exist, nothing to clean."
53+ fi
4754
4855 deploy :
4956 runs-on : ubuntu-latest
50- needs : [empty-s3-bucket ]
57+ needs : [clean-docs-folder ]
5158 environment : development
5259 steps :
5360 - name : Checkout repository
7683 aws-region : ${{ env.AWS_REGION_NAME }}
7784
7885 - name : Deploy to AWS S3
79- run : aws s3 sync ./${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET_NAME }}
86+ run : aws s3 sync ./${{ env.BUILD_DIR }} s3://${{ env.AWS_S3_BUCKET_NAME }}/docs/
87+
88+ - name : Clearing CloudFront cache
89+ run : aws cloudfront create-invalidation --distribution-id ${{ env.CLOUDFRONT_ID }} --paths "/docs/*"
8090
81- - name : Invalidate AWS CloudFront cache
82- run : aws cloudfront create-invalidation --distribution-id ${{ vars.AWS_CLOUDFRONT_DISTRIBUTION_ID }} --paths "/*"
91+ - name : Trigger Amplify redeploy
92+ run : |
93+ aws amplify start-deployment \
94+ --app-id ${{ secrets.AWS_AMPLIFY_APP_ID }} \
95+ --branch-name staging
0 commit comments