Skip to content

Commit b7d5f7e

Browse files
Produce actual deployments with links
1 parent 20e554a commit b7d5f7e

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
name: CI
22

3-
on: [push]
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
push:
10+
branches:
11+
- master
412

513
env:
614
BUILD_CACHE_KEY: ${{ github.sha }}-dist
@@ -38,6 +46,7 @@ jobs:
3846
key: '${{ env.BUILD_CACHE_KEY }}'
3947

4048
test:
49+
if: ${{ github.ref_name != 'master' }}
4150
runs-on: ubuntu-latest
4251
name: Test
4352
steps:
@@ -55,6 +64,10 @@ jobs:
5564
token: ${{ secrets.CODECOV_TOKEN }}
5665

5766
deploy-vite-example:
67+
concurrency:
68+
cancel-in-progress: true
69+
# one deployment per PR, not commit
70+
group: "${{ github.base_ref || github.ref_name }}:${{ github.head_ref || 'nil' }}:${{matrix.projects.project-id}}"
5871
strategy:
5972
matrix:
6073
projects:
@@ -65,6 +78,10 @@ jobs:
6578
project-id: prj_yBYBe1AJV0tbpTqxCMzcyRfFWXxP
6679
stream-api-key: xzwhhgtazy6h
6780
runs-on: ubuntu-latest
81+
environment:
82+
name: "${{ matrix.projects.name }} (${{ github.ref_name == 'master' && 'Production' || 'Preview' }})"
83+
deployment: true
84+
url: '${{ steps.deploy-to-vercel.outputs.deploy-url }}'
6885
# skip if build fails
6986
needs:
7087
- build
@@ -74,6 +91,7 @@ jobs:
7491
VERCEL_PROJECT_ID: ${{ matrix.projects.project-id }}
7592
VITE_STREAM_API_KEY: ${{ matrix.projects.stream-api-key }}
7693
NODE_ENV: production
94+
DEPLOY_TARGET: ${{ github.ref_name == 'master' && 'production' || 'preview' }}
7795
steps:
7896
- uses: actions/checkout@v6
7997

@@ -97,18 +115,11 @@ jobs:
97115
run: yarn install --frozen-lockfile
98116
shell: bash
99117

100-
- name: Vercel Pull/Build/Deploy (Preview)
118+
- name: Vercel Pull/Build/Deploy
101119
working-directory: examples/vite
102-
if: ${{ github.ref_name != 'master' }}
120+
id: deploy-to-vercel
103121
run: >-
104-
npx vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} &&
105-
npx vercel build &&
106-
npx vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
107-
108-
- name: Vercel Pull/Build/Deploy (Production)
109-
working-directory: examples/vite
110-
if: ${{ github.ref_name == 'master' }}
111-
run: >-
112-
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} &&
113-
npx vercel build --prod &&
114-
npx vercel deploy --prod --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
122+
npx vercel pull --yes --environment=${{ env.DEPLOY_TARGET }} --token=${{ secrets.VERCEL_TOKEN }} &&
123+
npx vercel build --target=${{ env.DEPLOY_TARGET }} &&
124+
npx vercel deploy --target=${{ env.DEPLOY_TARGET }} --prebuilt --token=${{ secrets.VERCEL_TOKEN }} |
125+
xargs -I % echo "deploy-url=%" >> "$GITHUB_OUTPUT"

0 commit comments

Comments
 (0)