Skip to content

Commit 25d2c5c

Browse files
committed
ci: adjust deploy and preview workflow
1 parent 02d13df commit 25d2c5c

3 files changed

Lines changed: 31 additions & 94 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/deploy.yml

Lines changed: 16 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,29 @@
11
name: Deploy to Production
22

3-
env:
4-
VERCEL_ORG_ID: ${{ secrets.ORG_ID }}
5-
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }}
6-
73
on:
84
push:
95
branches: [main]
106
paths:
7+
- index.html
118
- 'src/**'
129
- pnpm-lock.yaml
1310
- package.json
1411

1512
jobs:
16-
CI:
17-
uses: ./.github/workflows/ci.yml
13+
e2e-test:
14+
uses: tzuyi0817/workflows/.github/workflows/test.yml@v1
15+
with:
16+
install-other-deps: pnpm dlx playwright install --with-deps
17+
test: pnpm test:ci-e2e
1818

1919
deploy:
20-
needs: CI
21-
runs-on: ubuntu-latest
22-
environment: Production
23-
steps:
24-
- uses: actions/checkout@v6
25-
- name: install pnpm
26-
uses: pnpm/action-setup@v3
27-
28-
- name: install Vercel CLI
29-
run: pnpm install --global vercel@latest
30-
31-
- name: pull Vercel environment information
32-
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
33-
34-
- name: build project artifacts
35-
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
36-
37-
- name: deploy project artifacts to Vercel
38-
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
20+
needs: e2e-test
21+
uses: tzuyi0817/workflows/.github/workflows/deploy-vercel.yml@v1
22+
secrets:
23+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
24+
VERCEL_ORG_ID: ${{ secrets.ORG_ID }}
25+
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }}
26+
27+
with:
28+
environment: Production
29+
prod: true

.github/workflows/preview.yml

Lines changed: 15 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,24 @@
11
name: Deploy to Preview
22

3-
env:
4-
VERCEL_ORG_ID: ${{ secrets.ORG_ID }}
5-
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }}
6-
73
on:
84
pull_request:
95
types: [opened, synchronize, reopened]
106

117
jobs:
12-
CI:
13-
uses: ./.github/workflows/ci.yml
8+
e2e-test:
9+
uses: tzuyi0817/workflows/.github/workflows/test.yml@v1
10+
with:
11+
install-other-deps: pnpm dlx playwright install --with-deps
12+
test: pnpm test:ci-e2e
1413

1514
deploy:
16-
needs: CI
17-
runs-on: ubuntu-latest
18-
environment: Preview
19-
outputs:
20-
deploymentUrl: ${{ steps.deploy.outputs.deploymentUrl }}
21-
steps:
22-
- uses: actions/checkout@v6
23-
- name: install pnpm
24-
uses: pnpm/action-setup@v3
25-
26-
- name: install Vercel CLI
27-
run: pnpm install --global vercel@latest
28-
29-
- name: pull Vercel environment information
30-
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
31-
32-
- name: build project artifacts
33-
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
34-
35-
- name: deploy project artifacts to Vercel
36-
id: deploy
37-
run: |
38-
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > deploy.log
39-
echo "deploymentUrl=$(cat deploy.log)" >> $GITHUB_OUTPUT
40-
41-
comment:
42-
needs: deploy
43-
runs-on: ubuntu-latest
44-
permissions:
45-
issues: write
46-
pull-requests: write
47-
steps:
48-
- name: comment URL to PR
49-
uses: actions/github-script@v8
50-
with:
51-
script: |
52-
github.rest.issues.createComment({
53-
issue_number: context.issue.number,
54-
owner: context.repo.owner,
55-
repo: context.repo.repo,
56-
body: "Deployed at ${{ env.DEPLOYMENT_URL }}"
57-
})
58-
env:
59-
DEPLOYMENT_URL: ${{ needs.deploy.outputs.deploymentUrl }}
15+
needs: e2e-test
16+
uses: tzuyi0817/workflows/.github/workflows/deploy-vercel.yml@v1
17+
secrets:
18+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
19+
VERCEL_ORG_ID: ${{ secrets.ORG_ID }}
20+
VERCEL_PROJECT_ID: ${{ secrets.PROJECT_ID }}
21+
22+
with:
23+
environment: Preview
24+
create-comment: true

0 commit comments

Comments
 (0)