Skip to content

Commit 96f5a4d

Browse files
committed
chore: ci, deploy preview github action 추가
1 parent 9dd070d commit 96f5a4d

File tree

1 file changed

+113
-0
lines changed

1 file changed

+113
-0
lines changed

.github/workflows/ci.yml

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
name: Preview CI
2+
3+
env:
4+
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
5+
6+
on:
7+
pull_request:
8+
branches:
9+
- develop
10+
11+
jobs:
12+
ci:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 18
22+
cache: "yarn"
23+
24+
- name: Set yarn version
25+
id: set-version
26+
run: |
27+
yarn set version 4.1.1
28+
echo "YARN_VERSION=$(yarn -v)" >> $GITHUB_OUTPUT
29+
30+
- name: Yarn cache - PnP
31+
uses: actions/cache@v4
32+
with:
33+
path: |
34+
.yarn/cache
35+
.pnp.*
36+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.set-version.outputs.YARN_VERSION }}
37+
restore-keys: |
38+
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-
39+
40+
- name: Install dependencies
41+
run: yarn
42+
43+
- name: Run build
44+
run: yarn build
45+
46+
- name: Run unit test
47+
run: yarn test
48+
49+
deploy-to-vercel:
50+
runs-on: ubuntu-latest
51+
outputs:
52+
statis: ${{ job.status }}
53+
preview_url: ${{ steps.deploy-vercel.outputs.preview_url }}
54+
currnent_time: ${{ steps.current-time.outputs.formattedTime }}
55+
needs: ci
56+
steps:
57+
- name: Checkout
58+
uses: actions/checkout@v4
59+
60+
- name: Setup node
61+
uses: actions/setup-node@v4
62+
with:
63+
node-version: 18
64+
cache: "yarn"
65+
66+
- name: Set yarn version
67+
id: set-version
68+
run: |
69+
yarn set version 4.1.1
70+
echo "YARN_VERSION=$(yarn -v)" >> $GITHUB_OUTPUT
71+
72+
- name: Yarn cache - PnP
73+
uses: actions/cache@v4
74+
with:
75+
path: |
76+
.yarn/cache
77+
.pnp.*
78+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{ steps.set-version.outputs.YARN_VERSION }}
79+
restore-keys: |
80+
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-
81+
82+
- name: Install dependencies
83+
run: yarn
84+
85+
- name: Deploy to Vercel
86+
id: deploy-vercel
87+
run: |
88+
npm install --global vercel@latest
89+
vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
90+
vercel build --token=${{ secrets.VERCEL_TOKEN }}
91+
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > vercel-output.txt
92+
echo "preview_url=$(cat vercel-output.txt)" >> $GITHUB_OUTPUT
93+
94+
- name: Get current time
95+
uses: josStorer/get-current-time@v2
96+
id: current-time
97+
with:
98+
format: "YYYY년 MM월 DD일 HH시 mm분"
99+
utcOffset: "+09:00"
100+
101+
github-privew-comment:
102+
runs-on: ubuntu-latest
103+
needs: [deploy-to-vercel]
104+
steps:
105+
- name: Comment PR
106+
uses: thollander/actions-comment-pull-request@v3
107+
with:
108+
comment-tag: ${{ github.event.number }}
109+
message: |
110+
111+
🧷 Preview: ${{ needs.deploy-to-vercel.outputs.preview_url }}
112+
113+
⏰ Update: ${{ needs.deploy-to-vercel.outputs.currnent_time }}

0 commit comments

Comments
 (0)