[TEST/YAF-000] ๋ฐ๋ชจ ์ฑ ๋ฐฐํฌ #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Orbit CD | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
cd: | |
name: Continuous Deployment | |
runs-on: ubuntu-latest | |
steps: | |
# 1. Code Checkout | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# 2. Gradle Cache | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v4 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
# 3. JDK 17 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 17 | |
distribution: 'corretto' | |
cache: gradle | |
# 4. Grant Execute Permission | |
- name: Change gradlew permissions | |
run: chmod +x gradlew | |
# 5. Install Firebase CLI | |
- name: Install Firebase CLI | |
run: curl -sL https://firebase.tools | bash | |
# 6. Decode google-services.json | |
- name: Decode google-services.json | |
env: | |
FIREBASE_SECRET: ${{ secrets.FIREBASE_SECRET }} | |
run: echo $FIREBASE_SECRET | base64 --decode > app/google-services.json | |
# 7. local.properties | |
- name: Add local.properties | |
env: | |
BASE_URL: ${{ secrets.BASE_URL }} | |
run: | | |
echo "base.url=\"$BASE_URL\"" >> app/local.properties | |
# 8. Ktlint | |
- name: Run Ktlint Check | |
run: ./gradlew ktlintCheck --stacktrace | |
# 9. Debug APK Build | |
- name: Build Debug APK | |
run: ./gradlew assembleDebug --stacktrace | |
# 10. Release AAB Build | |
- name: Build Release AAB | |
run: ./gradlew bundleRelease --stacktrace | |
# 11. Release APK Build | |
- name: Build Release APK | |
run: ./gradlew assembleRelease --stacktrace | |
# 12. AAB Artifact Upload | |
- name: Upload Release AAB | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-aab | |
path: app/build/outputs/bundle/release/app-release.aab | |
# 13. APK Artifact Upload | |
- name: Upload Release APK | |
uses: actions/upload-artifact@v4 | |
with: | |
name: release-apk | |
path: app/build/outputs/apk/release/app-release.apk | |
# 14. Set up Firebase Service Account Credentials | |
- name: Set up Firebase Service Account Credentials | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS_JSON: ${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_JSON }} | |
run: | | |
echo "$GOOGLE_APPLICATION_CREDENTIALS_JSON" | base64 --decode > $HOME/firebase-credentials.json | |
echo "๐ฅ Firebase Credentials JSON ์์ฑ ์๋ฃ!" | |
ls -l $HOME/firebase-credentials.json | |
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" | |
# 15. Firebase CLI ์ธ์ฆ ํ์ธ | |
- name: Check Firebase CLI Authentication | |
run: | | |
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
echo "๐ GOOGLE_APPLICATION_CREDENTIALS ์ค์ ๊ฐ:" | |
echo $GOOGLE_APPLICATION_CREDENTIALS | |
ls -l $GOOGLE_APPLICATION_CREDENTIALS | |
echo "๐ ํ์ฌ Firebase ํ๋ก์ ํธ ๋ชฉ๋ก ํ์ธ:" | |
firebase projects:list || (echo "โ Firebase ์ธ์ฆ ์คํจ!"; exit 1) | |
# 16. Firebase App Distribution Upload | |
- name: Upload APK to Firebase App Distribution | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: $HOME/firebase-credentials.json | |
FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} | |
run: | | |
echo "๐ฅ FIREBASE_APP_ID ํ์ธ: $FIREBASE_APP_ID" | |
# ๋ง์ฝ FIREBASE_APP_ID๊ฐ ์์ผ๋ฉด ์๋ฌ ์ถ๋ ฅ ํ ์ข ๋ฃ | |
if [ -z "$FIREBASE_APP_ID" ]; then | |
echo "โ ERROR: FIREBASE_APP_ID๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. GitHub Secrets์์ ํ์ธํ์ธ์." | |
exit 1 | |
fi | |
# GOOGLE_APPLICATION_CREDENTIALS๋ฅผ ๋ค์ ์ค์ | |
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/firebase-credentials.json | |
echo "GOOGLE_APPLICATION_CREDENTIALS=$GOOGLE_APPLICATION_CREDENTIALS" | |
firebase appdistribution:distribute app/build/outputs/apk/release/app-release.apk \ | |
--app "$FIREBASE_APP_ID" \ | |
--release-notes "๐ ์๋ก์ด ๋ฐ๋ชจ ๋ฒ์ ์ด ๋ฐฐํฌ๋์์ต๋๋ค!" \ | |
--groups "orbit-tester-group" | |
# 17. Notify Discord | |
- name: Notify Discord | |
env: | |
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} | |
run: | | |
curl -H "Content-Type: application/json" \ | |
-X POST \ | |
-d '{"content": "๐ ์๋ก์ด ๋ฐ๋ชจ ๋ฒ์ ์ด Firebase App Distribution์ ์ ๋ก๋๋์์ต๋๋ค!\nAPK ๋ค์ด๋ก๋: https://appdistribution.firebase.google.com"}' \ | |
$DISCORD_WEBHOOK_URL |