diff --git a/.github/workflows/android.yml b/.github/workflows/android.yml index 907b672df..5a0e95728 100644 --- a/.github/workflows/android.yml +++ b/.github/workflows/android.yml @@ -8,15 +8,15 @@ on: branches: - develop +permissions: + contents: read + pull-requests: write + jobs: build: # develop push는 허용, develop으로의 PR 중 release/* 브랜치에서 온 PR만 허용 if: > - github.event_name == 'push' || - ( - github.event_name == 'pull_request' && - startsWith(github.event.pull_request.head.ref, 'release/') - ) + github.event_name == 'push' || github.event_name == 'pull_request' runs-on: ubuntu-latest steps: @@ -70,50 +70,52 @@ jobs: run: chmod +x gradlew - name: Assemble Debug APK + if: > + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') run: ./gradlew assembleDebug - - name: Assemble Release APK - run: ./gradlew assembleRelease - - name: Upload Debug APK artifact + if: > + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') uses: actions/upload-artifact@v4 with: name: debug-apk path: app/build/outputs/apk/debug/*.apk + - name: Assemble Release APK + if: > + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') + run: ./gradlew assembleRelease + - name: Upload Release APK artifact + if: > + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') uses: actions/upload-artifact@v4 with: name: release-apk path: app/build/outputs/apk/release/*.apk - - name: Install Firebase CLI - if: > - github.event_name == 'pull_request' && - github.event.action == 'opened' && - startsWith(github.event.pull_request.head.ref, 'release/') - run: | - npm i -g firebase-tools - - name: Distribute Debug APK to Firebase App Distribution + # Release만 Firebase 배포 + - name: Install Firebase CLI if: > github.event_name == 'pull_request' && - github.event.action == 'opened' && - startsWith(github.event.pull_request.head.ref, 'release/') - env: - FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} - FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} - run: | - firebase appdistribution:distribute app/build/outputs/apk/debug/*.apk \ - --app "$FIREBASE_APP_ID" \ - --groups "eat-ssu-android-qa" \ - --release-notes "Debug | PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" \ - --token "$FIREBASE_TOKEN" + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') + run: npm i -g firebase-tools - name: Distribute Release APK to Firebase App Distribution if: > github.event_name == 'pull_request' && - github.event.action == 'opened' && - startsWith(github.event.pull_request.head.ref, 'release/') + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') env: FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }} FIREBASE_APP_ID: ${{ secrets.FIREBASE_APP_ID }} @@ -123,3 +125,29 @@ jobs: --groups "eat-ssu-android-qa" \ --release-notes "Release | PR #${{ github.event.pull_request.number }}: ${{ github.event.pull_request.title }}" \ --token "$FIREBASE_TOKEN" + + + # Debug는 Artifact로만 공유 + PR 코멘트 + - name: Comment PR with artifact download 안내 + if: > + github.event_name == 'pull_request' && + startsWith(github.event.pull_request.head.ref, 'release/') && + (github.event.action == 'opened' || github.event.action == 'synchronize' || github.event.action == 'reopened') + uses: actions/github-script@v7 + with: + script: | + const runUrl = `${context.serverUrl}/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; + const body = + [ + `✅ CI 완료`, + ``, + `- Debug APK: GitHub Actions Artifacts에서 다운로드 (run 링크: ${runUrl})`, + `- Release APK: Firebase App Distribution으로 배포됨 (그룹: eat-ssu-android-qa)`, + ].join('\n'); + + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.payload.pull_request.number, + body, + });