Skip to content

Commit ca2b620

Browse files
Merge pull request #6 from piyush-jaiswal/ci/block-deployment-on-tests
Block vercel deployment on test success
2 parents 7b08461 + 3ba7cdc commit ca2b620

File tree

4 files changed

+84
-5
lines changed

4 files changed

+84
-5
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Vercel Preview Deployment
2+
3+
env:
4+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6+
7+
on:
8+
pull_request:
9+
branches: [ "master" ]
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: "vercel-preview-${{ github.event.pull_request.number }}"
14+
cancel-in-progress: true
15+
16+
jobs:
17+
test:
18+
uses: ./.github/workflows/tests.yml
19+
20+
deploy-preview:
21+
needs: [test]
22+
runs-on: ubuntu-latest
23+
# Do not run for PR from forks
24+
if: github.event.pull_request.head.repo.full_name == github.repository
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Install Vercel CLI
31+
run: npm install --global [email protected]
32+
33+
- name: Pull Vercel Environment Information
34+
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
35+
36+
- name: Build Project Artifacts
37+
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
38+
39+
- name: Deploy Project Artifacts to Vercel
40+
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Vercel Production Deployment
2+
3+
env:
4+
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
5+
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
6+
7+
on:
8+
push:
9+
branches: [ "master" ]
10+
workflow_dispatch:
11+
12+
concurrency:
13+
group: "vercel-production-${{ github.ref }}"
14+
cancel-in-progress: false # waits for the previous one to finish
15+
16+
jobs:
17+
test:
18+
uses: ./.github/workflows/tests.yml
19+
20+
deploy-production:
21+
needs: [test]
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout code
26+
uses: actions/checkout@v4
27+
28+
- name: Install Vercel CLI
29+
run: npm install --global [email protected]
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 --token=${{ secrets.VERCEL_TOKEN }}
36+
37+
- name: Deploy Project Artifacts to Vercel
38+
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}

.github/workflows/tests.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
name: Tests
22

33
on:
4-
push:
5-
branches: [ "master" ]
6-
pull_request:
7-
branches: [ "master" ]
4+
workflow_call:
85
workflow_dispatch:
96

107
jobs:

vercel.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,9 @@
44
"src": "/(.*)",
55
"dest": "/api/vercel_function"
66
}
7-
]
7+
],
8+
9+
"git": {
10+
"deploymentEnabled": false
11+
}
812
}

0 commit comments

Comments
 (0)