Skip to content

Commit 51d3df0

Browse files
Refactor CI/CD workflow to enhance Vercel deployment process and environment handling
1 parent d9fdb20 commit 51d3df0

File tree

1 file changed

+23
-6
lines changed

1 file changed

+23
-6
lines changed

.github/workflows/main.yml

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: CI/CD Workflow--> Deploy and run E2E tests
1+
name: CI/CD Workflow --> Deploy and Run E2E Tests
22

33
on:
44
pull_request:
@@ -18,21 +18,37 @@ jobs:
1818
uses: actions/checkout@v3
1919

2020
- name: Install Vercel CLI
21-
run: npm install -g vercel
21+
run: npm install --global vercel@latest
22+
23+
- name: Pull Vercel Environment Information
24+
run: |
25+
if [[ "${{ github.event_name }}" == "release" ]]; then
26+
vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
27+
else
28+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
29+
fi
30+
31+
- name: Build Project Artifacts
32+
run: |
33+
if [[ "${{ github.event_name }}" == "release" ]]; then
34+
vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
35+
else
36+
vercel build --token=${{ secrets.VERCEL_TOKEN }}
37+
fi
2238
2339
- name: Deploy to Vercel
2440
id: deploy
2541
run: |
26-
vercel pull --yes --environment=preview --token ${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
2742
if [[ "${{ github.event_name }}" == "release" ]]; then
28-
DEPLOY_URL=$(vercel deploy --prod --token ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
43+
DEPLOY_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }} | tail -1)
2944
else
30-
DEPLOY_URL=$(vercel deploy --pre --token ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
45+
DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} | tail -1)
3146
fi
3247
echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV
3348
echo "Deployed to: $DEPLOY_URL"
49+
3450
env:
35-
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
51+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
3652

3753
e2e:
3854
name: Run E2E Tests
@@ -57,6 +73,7 @@ jobs:
5773
env:
5874
BASE_URL: ${{ env.DEPLOYMENT_URL }}
5975

76+
6077
# notify:
6178
# name: Send Slack Notification
6279
# runs-on: ubuntu-latest

0 commit comments

Comments
 (0)