Merge pull request #110 from SynclyProject/refactor/109 #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy to S3 and CloudFront | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| cache: 'yarn' | |
| cache-dependency-path: Syncly/yarn.lock | |
| - name: Install dependencies | |
| working-directory: ./Syncly | |
| run: yarn install --frozen-lockfile | |
| - name: Clean old build | |
| working-directory: ./Syncly | |
| run: rm -rf dist | |
| - name: Build | |
| working-directory: ./Syncly | |
| env: | |
| VITE_API_URL: ${{ secrets.VITE_API_URL }} | |
| VITE_API_BASE_URL: ${{ secrets.VITE_API_BASE_URL }} | |
| VITE_LIVEKIT_URL: ${{ secrets.VITE_LIVEKIT_URL }} | |
| VITE_VIEW_IMAGE_URL: ${{ secrets.VITE_VIEW_IMAGE_URL }} | |
| VITE_OAUTH_REDIRECT_PATH: ${{ secrets.VITE_OAUTH_REDIRECT_PATH }} | |
| VITE_WEBSOCKET_URL: ${{ secrets.VITE_WEBSOCKET_URL }} | |
| run: yarn build | |
| - name: Configure AWS credentials | |
| uses: aws-actions/configure-aws-credentials@v4 | |
| with: | |
| aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region: ${{ secrets.AWS_REGION }} | |
| - name: Deploy to S3 | |
| working-directory: ./Syncly | |
| run: | | |
| aws s3 sync dist/ s3://${{ secrets.S3_BUCKET_NAME }} --delete | |
| - name: Invalidate CloudFront cache | |
| run: | | |
| aws cloudfront create-invalidation \ | |
| --distribution-id ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }} \ | |
| --paths "/*" | |