-
Notifications
You must be signed in to change notification settings - Fork 0
155 lines (129 loc) · 6.57 KB
/
stage-deploy.yml
File metadata and controls
155 lines (129 loc) · 6.57 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
name: Stage Deploy
on:
push:
branches:
- stage-deploy
jobs:
# iOS와 Android 병렬 실행을 위한 Matrix Strategy
deploy:
name: Deploy to Stage - ${{ matrix.platform }}
runs-on: ubuntu-latest
strategy:
matrix:
platform: [ios, android]
fail-fast: false # 한쪽 실패해도 다른 쪽 계속 진행
steps:
- name: 🏗 Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: 🏗 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: 🏗 Setup pnpm
uses: pnpm/action-setup@v4
- name: 📦 Install dependencies
run: pnpm install --frozen-lockfile
- name: 🏗 Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: 🔍 Generate current fingerprint
id: fingerprint
run: |
cd apps/conch
if [ "${{ matrix.platform }}" = "ios" ]; then
# iOS 관련 파일만 해싱
HASH=$(find ios package.json app.json -type f 2>/dev/null | sort | xargs cat | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
echo "iOS fingerprint: $HASH"
else
# Android 관련 파일만 해싱
HASH=$(find android package.json app.json -type f 2>/dev/null | sort | xargs cat | sha256sum | cut -d' ' -f1)
echo "hash=$HASH" >> $GITHUB_OUTPUT
echo "Android fingerprint: $HASH"
fi
- name: 🔍 Get previous fingerprint from git
id: previous-fingerprint
run: |
cd apps/conch
git fetch origin ${{ github.ref_name }} --depth=2
PREV_COMMIT=$(git rev-parse HEAD~1 2>/dev/null || echo "")
if [ -n "$PREV_COMMIT" ]; then
# 이전 커밋으로 체크아웃
git checkout $PREV_COMMIT -- package.json ${{ matrix.platform }} app.json 2>/dev/null || true
if [ "${{ matrix.platform }}" = "ios" ]; then
PREV_HASH=$(find ios package.json app.json -type f 2>/dev/null | sort | xargs cat | sha256sum | cut -d' ' -f1 || echo "none")
else
PREV_HASH=$(find android package.json app.json -type f 2>/dev/null | sort | xargs cat | sha256sum | cut -d' ' -f1 || echo "none")
fi
echo "previous_hash=$PREV_HASH" >> $GITHUB_OUTPUT
echo "Previous ${{ matrix.platform }} fingerprint: $PREV_HASH"
# 원래대로 복구
git checkout HEAD -- package.json ${{ matrix.platform }} app.json 2>/dev/null || true
else
echo "previous_hash=none" >> $GITHUB_OUTPUT
fi
continue-on-error: true
- name: 📊 Compare fingerprints
id: compare
run: |
CURRENT="${{ steps.fingerprint.outputs.hash }}"
PREVIOUS="${{ steps.previous-fingerprint.outputs.previous_hash }}"
echo "=== ${{ matrix.platform }} ==="
echo "Current: $CURRENT"
echo "Previous: $PREVIOUS"
# 빌드 필요 여부
if [ "$PREVIOUS" = "none" ] || [ "$CURRENT" != "$PREVIOUS" ]; then
echo "needs_build=true" >> $GITHUB_OUTPUT
echo "🔨 ${{ matrix.platform }}: Native changes detected - will build"
else
echo "needs_build=false" >> $GITHUB_OUTPUT
echo "✅ ${{ matrix.platform }}: No native changes - will use EAS Update"
fi
- name: 🚀 EAS Update (JS only changes)
if: steps.compare.outputs.needs_build == 'false'
run: |
cd apps/conch
eas update --platform ${{ matrix.platform }} --channel stage --message "Auto update ${{ matrix.platform }} from ${{ github.ref_name }} [${{ github.sha }}]" --non-interactive
- name: 🔨 EAS Build & Submit (Native changes detected)
id: build
if: steps.compare.outputs.needs_build == 'true'
run: |
cd apps/conch
set -o pipefail
eas build --platform ${{ matrix.platform }} --profile preview --auto-submit --non-interactive 2>&1 | tee build-output-${{ matrix.platform }}.txt
BUILD_URL=$(grep -o 'https://expo.dev/accounts/.*/projects/.*/builds/[^"]*' build-output-${{ matrix.platform }}.txt | head -1 || echo "")
echo "build_url=$BUILD_URL" >> $GITHUB_OUTPUT
- name: 📝 Deployment Summary - ${{ matrix.platform }}
if: always()
run: |
PLATFORM_EMOJI="${{ matrix.platform == 'ios' && '📱' || '🤖' }}"
PLATFORM_NAME="${{ matrix.platform == 'ios' && 'iOS' || 'Android' }}"
echo "## $PLATFORM_EMOJI $PLATFORM_NAME Deployment" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Branch:** \`${{ github.ref_name }}\`" >> $GITHUB_STEP_SUMMARY
echo "**Commit:** [\`${GITHUB_SHA:0:7}\`](https://github.com/${{ github.repository }}/commit/${{ github.sha }})" >> $GITHUB_STEP_SUMMARY
echo "**Fingerprint:** \`${{ steps.fingerprint.outputs.hash }}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.compare.outputs.needs_build }}" = "true" ]; then
echo "**Action:** 🔨 Build + Submit" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ${{ steps.build.outcome == 'success' && '✅ Success' || (steps.build.outcome == 'failure' && '❌ Failed' || '⏭️ Skipped') }}" >> $GITHUB_STEP_SUMMARY
echo "**Profile:** preview" >> $GITHUB_STEP_SUMMARY
echo "**Destination:** ${{ matrix.platform == 'ios' && 'TestFlight' || 'Play Store Alpha' }}" >> $GITHUB_STEP_SUMMARY
if [ -n "${{ steps.build.outputs.build_url }}" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Build URL:** [${{ steps.build.outputs.build_url }}](${{ steps.build.outputs.build_url }})" >> $GITHUB_STEP_SUMMARY
fi
if [ "${{ steps.build.outcome }}" = "failure" ]; then
echo "" >> $GITHUB_STEP_SUMMARY
echo "⚠️ **Build or submission failed.** Check the logs for details." >> $GITHUB_STEP_SUMMARY
fi
else
echo "**Action:** 🚀 EAS Update (OTA)" >> $GITHUB_STEP_SUMMARY
echo "**Status:** ✅ Success" >> $GITHUB_STEP_SUMMARY
echo "**Channel:** stage" >> $GITHUB_STEP_SUMMARY
echo "**Reason:** No native changes detected" >> $GITHUB_STEP_SUMMARY
fi