From 2de19259d3fcb40f3cc4a7dfb45559486b439364 Mon Sep 17 00:00:00 2001 From: Serhii Date: Thu, 22 Aug 2024 07:18:06 +0300 Subject: [PATCH] chore:ci/cd --- .github/workflows/deploy.yml | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 67c8309..01f46c1 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -86,22 +86,24 @@ jobs: - name: Build frontend working-directory: frontend run: npm run build + + - name: Configure AWS credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_REGION }} # Step 6: Deploy to S3 - - name: Deploy to S3 + - name: Replace S3 bucket contents run: | - aws s3 sync ./frontend/build s3://${{ secrets.S3_BUCKET }} --deleted - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} + aws s3 rm s3://${{ secrets.S3_BUCKET }} --recursive + aws s3 cp frontend/dist s3://${{ secrets.S3_BUCKET }} --recursive + # Step 7: CloudFront - name: Invalidate CloudFront cache run: | aws cloudfront create-invalidation --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID}} --paths "/*" - env: - AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} - AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} - AWS_REGION: ${{ secrets.AWS_REGION }} + # Step 8: Save cache (only on the master branch) - name: Save cache uses: actions/cache/save@v3 @@ -109,4 +111,4 @@ jobs: with: path: frontend/node_modules/ - key: deploy-${{ github.sha }}-${{ hashFiles('frontend/package-lock.json') }}-${{ hashFiles('linguaphoto/requirements.txt') }} + key: deploy-${{ github.sha }}-${{ hashFiles('frontend/package-lock.json') }}-${{ hashFiles('linguaphoto/requirements.txt') }} \ No newline at end of file