Skip to content

Commit c829d41

Browse files
Refactor CI/CD workflow to enhance deployment and E2E testing processes
1 parent a2c8bf8 commit c829d41

File tree

1 file changed

+74
-75
lines changed

1 file changed

+74
-75
lines changed

.github/workflows/main.yml

Lines changed: 74 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,77 @@
1-
# name: CI/CD Workflow --> Deploy and Run E2E Tests
2-
3-
# on:
4-
# pull_request:
5-
# push:
6-
# branches:
7-
# - main
8-
# release:
9-
# types: [created]
10-
11-
# jobs:
12-
# deploy:
13-
# name: Deploy to Vercel
14-
# runs-on: ubuntu-latest
15-
16-
# steps:
17-
# - name: Checkout Code
18-
# uses: actions/checkout@v3
19-
20-
# - name: Install Vercel CLI
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_MY_PROJECT }}
27-
# else
28-
# vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
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_MY_PROJECT }}
35-
# else
36-
# vercel build --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
37-
# fi
38-
39-
# - name: Deploy to Vercel
40-
# id: deploy
41-
# run: |
42-
# if [[ "${{ github.event_name }}" == "release" ]]; then
43-
# DEPLOY_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
44-
# else
45-
# DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
46-
# fi
47-
# echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV
48-
# echo "Deployed to: $DEPLOY_URL"
49-
50-
# env:
51-
# VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
52-
53-
# e2e:
54-
# name: Run E2E Tests
55-
# runs-on: ubuntu-latest
56-
# needs: deploy
57-
58-
# steps:
59-
# - name: Checkout Code
60-
# uses: actions/checkout@v3
61-
62-
# - name: Install pnpm
63-
# run: npm install -g pnpm
64-
65-
# - name: Install Dependencies
66-
# run: pnpm install
67-
68-
# - name: Install Playwright
69-
# run: pnpm playwright install
70-
71-
# - name: Run Playwright Tests
72-
# run: pnpm playwright test
73-
# env:
74-
# BASE_URL: ${{ env.DEPLOYMENT_URL }}
75-
1+
name: CI/CD Workflow --> Deploy and Run E2E Tests
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches:
7+
- main
8+
release:
9+
types: [created]
10+
11+
jobs:
12+
deploy:
13+
name: Deploy to Vercel
14+
runs-on: ubuntu-latest
15+
16+
steps:
17+
- name: Checkout Code
18+
uses: actions/checkout@v3
19+
20+
- name: Install Vercel CLI
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_MY_PROJECT }}
27+
else
28+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
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_MY_PROJECT }}
35+
else
36+
vercel build --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }}
37+
fi
38+
39+
- name: Deploy to Vercel
40+
id: deploy
41+
run: |
42+
if [[ "${{ github.event_name }}" == "release" ]]; then
43+
DEPLOY_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
44+
else
45+
DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1)
46+
fi
47+
echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV
48+
echo "Deployed to: $DEPLOY_URL"
49+
50+
env:
51+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
52+
53+
e2e:
54+
name: Run E2E Tests
55+
runs-on: ubuntu-latest
56+
needs: deploy
57+
58+
steps:
59+
- name: Checkout Code
60+
uses: actions/checkout@v3
61+
62+
- name: Install pnpm
63+
run: npm install -g pnpm
64+
65+
- name: Install Dependencies
66+
run: pnpm install
67+
68+
- name: Install Playwright
69+
run: pnpm playwright install
70+
71+
- name: Run Playwright Tests
72+
run: pnpm playwright test
73+
env:
74+
BASE_URL: ${{ env.DEPLOYMENT_URL }}
7675
#notify:
7776
# name: Notify Team on Failure
7877
# runs-on: ubuntu-latest

0 commit comments

Comments
 (0)