|
| 1 | +name: Deployment |
| 2 | +on: [push, pull_request] |
| 3 | +jobs: |
| 4 | + vercel: |
| 5 | + runs-on: ubuntu-latest |
| 6 | + strategy: |
| 7 | + matrix: |
| 8 | + node-version: [18.x] |
| 9 | + steps: |
| 10 | + - name: Checkout |
| 11 | + uses: actions/checkout@v3 |
| 12 | + - name: Use Node.js ${{ matrix.node-version }} |
| 13 | + uses: actions/setup-node@v3 |
| 14 | + with: |
| 15 | + node-version: ${{ matrix.node-version }} |
| 16 | + cache: "npm" |
| 17 | + - name: Get npm cache directory |
| 18 | + id: npm-cache-dir |
| 19 | + run: | |
| 20 | + echo "::set-output name=dir::$(npm config get cache)" |
| 21 | + - uses: actions/cache@v3 |
| 22 | + id: npm-cache |
| 23 | + if: steps.npm-cache.outputs.cache-hit != 'true' |
| 24 | + with: |
| 25 | + path: ${{ steps.npm-cache-dir.outputs.dir }} |
| 26 | + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-node- |
| 29 | + - run: npm install |
| 30 | + working-directory: ./pwa |
| 31 | + - name: Lint |
| 32 | + run: npm run lint |
| 33 | + working-directory: ./pwa |
| 34 | + - name: Build |
| 35 | + run: npm run build |
| 36 | + working-directory: ./pwa |
| 37 | + - name: Start Deployment |
| 38 | + uses: bobheadxi/deployments@v0.4.3 |
| 39 | + id: deployment-preview |
| 40 | + with: |
| 41 | + step: start |
| 42 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 43 | + env: Preview |
| 44 | + - name: Deploy to Preview |
| 45 | + id: vercel-action-preview |
| 46 | + uses: amondnet/vercel-action@v20 |
| 47 | + with: |
| 48 | + vercel-token: ${{ secrets.VERCEL_TOKEN }} |
| 49 | + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} |
| 50 | + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} |
| 51 | + scope: ${{ secrets.VERCEL_ORG_ID }} |
| 52 | + working-directory: ./pwa |
| 53 | + - name: Deploy to Production |
| 54 | + uses: amondnet/vercel-action@v20 |
| 55 | + id: vercel-action-production |
| 56 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 57 | + with: |
| 58 | + vercel-token: ${{ secrets.VERCEL_TOKEN }} |
| 59 | + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} |
| 60 | + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} |
| 61 | + github-comment: false |
| 62 | + vercel-args: "--prod" |
| 63 | + working-directory: ./pwa |
| 64 | + - name: Update Deployment Status |
| 65 | + uses: bobheadxi/deployments@v0.4.3 |
| 66 | + if: github.ref != 'refs/heads/main' |
| 67 | + with: |
| 68 | + step: finish |
| 69 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 70 | + status: ${{ job.status }} |
| 71 | + deployment_id: ${{ steps.deployment-preview.outputs.deployment_id }} |
| 72 | + env_url: ${{ steps.vercel-action-preview.outputs.preview-url }} |
0 commit comments