|
| 1 | +name: Preview Deployment |
| 2 | +permissions: |
| 3 | + actions: write |
| 4 | + contents: read |
| 5 | + checks: read |
| 6 | + pull-requests: write |
| 7 | + deployments: write |
| 8 | + |
| 9 | +env: |
| 10 | + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} |
| 11 | +on: |
| 12 | + pull_request: |
| 13 | + types: [opened, synchronize] |
| 14 | +jobs: |
| 15 | + pre_job: |
| 16 | + runs-on: ubuntu-latest |
| 17 | + outputs: |
| 18 | + should_skip: ${{ steps.skip_check.outputs.should_skip }} |
| 19 | + steps: |
| 20 | + - id: skip_check |
| 21 | + uses: fkirc/skip-duplicate-actions@v5 |
| 22 | + with: |
| 23 | + # All of these options are optional, so you can remove them if you are happy with the defaults |
| 24 | + concurrent_skipping: 'outdated_runs' |
| 25 | +# paths_ignore: '["**/README.md", "**/ag-guideline.md", "**/docs/**", ".github/**"]' |
| 26 | + cancel_others: 'true' |
| 27 | + |
| 28 | + changed-packages: |
| 29 | + needs: pre_job |
| 30 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 31 | + name: Determine which apps changed |
| 32 | + uses: ./.github/workflows/changed-packages.yaml |
| 33 | + Deploy-Preview: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + needs: [pre_job, changed-packages] |
| 36 | + if: needs.pre_job.outputs.should_skip != 'true' |
| 37 | + steps: |
| 38 | + - name: Checkout code |
| 39 | + uses: actions/checkout@v3 |
| 40 | + with: |
| 41 | + fetch-depth: 2 |
| 42 | + ref: ${{ needs.check-app.outputs.branch }} |
| 43 | + - name: Prepare Environment |
| 44 | + uses: ./.github/actions/setup-env |
| 45 | + timeout-minutes: 10 |
| 46 | + with: |
| 47 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 48 | + |
| 49 | + - name: Deploy API_HARMONIZATION |
| 50 | + if: contains(toJson(fromJson(needs.changed-packages.outputs.package_changed).packages), 'api') && always() |
| 51 | + env: |
| 52 | + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_API_HARMONIZATION_PROJECT_ID }} |
| 53 | + uses: ./.github/actions/preview |
| 54 | + timeout-minutes: 10 |
| 55 | + with: |
| 56 | + vercel-token: ${{ secrets.VERCEL_ACCESS_TOKEN }} # Required |
| 57 | + github-token: ${{ secrets.GITHUB_TOKEN }} #Optional |
| 58 | + vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required |
| 59 | + vercel-project-id: ${{ secrets.VERCEL_API_HARMONIZATION_PROJECT_ID }} #Required |
| 60 | + vercel-project-name: 'api-harmonization' |
| 61 | + |
| 62 | + - name: Deploy FRONTEND |
| 63 | + if: contains(toJson(fromJson(needs.changed-packages.outputs.package_changed).packages), 'frontend') && always() |
| 64 | + env: |
| 65 | + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_FRONTEND_PROJECT_ID }} |
| 66 | + uses: ./.github/actions/preview |
| 67 | + timeout-minutes: 10 |
| 68 | + with: |
| 69 | + vercel-token: ${{ secrets.VERCEL_ACCESS_TOKEN }} # Required |
| 70 | + github-token: ${{ secrets.GITHUB_TOKEN }} #Optional |
| 71 | + vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required |
| 72 | + vercel-project-id: ${{ secrets.VERCEL_FRONTEND_PROJECT_ID }} #Required |
| 73 | + vercel-project-name: 'frontend' |
0 commit comments