-
Notifications
You must be signed in to change notification settings - Fork 4
73 lines (58 loc) · 1.79 KB
/
ci.yml
File metadata and controls
73 lines (58 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: CI
on:
pull_request:
branches:
- main
- master
- develop
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
lint-and-build:
name: Lint & Build
runs-on: ubuntu-latest
env:
NEXT_TELEMETRY_DISABLED: "1"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Inject BACKEND_URL
shell: bash
env:
BACKEND_URL_PRODUCTION: ${{ secrets.BACKEND_URL_PRODUCTION }}
BACKEND_URL_STAGING: ${{ secrets.BACKEND_URL_STAGING }}
run: |
# fork PR은 보안상 secrets가 전달되지 않음 → 공개 URL(또는 더미)로 빌드만 통과
if [ "${{ github.event.pull_request.head.repo.fork }}" = "true" ]; then
echo "BACKEND_URL=https://primerflow-be.onrender.com" >> "$GITHUB_ENV"
exit 0
fi
if [ "${{ github.base_ref }}" = "main" ] || [ "${{ github.base_ref }}" = "master" ]; then
selected="$BACKEND_URL_PRODUCTION"
key="BACKEND_URL_PRODUCTION"
else
selected="$BACKEND_URL_STAGING"
key="BACKEND_URL_STAGING"
fi
if [ -z "$selected" ]; then
echo "::error::Missing secret $key"
echo "::error::Set it in Settings -> Secrets and variables -> Actions -> Repository secrets"
exit 1
fi
echo "BACKEND_URL=$selected" >> "$GITHUB_ENV"
- name: Lint
run: npm run lint
- name: Test
run: npm test
- name: Build
run: npm run build