From e26d002264e97388e3cfdd0128e337524a6afa14 Mon Sep 17 00:00:00 2001 From: JUNWON LEE Date: Wed, 11 Sep 2024 13:06:08 +0900 Subject: [PATCH] =?UTF-8?q?[1.1.0/AN=5FCD]=20Discord=EB=A1=9C=20alpha=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20apk=20=EC=A0=84=EB=8B=AC=20(#290)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * πŸŽ‰ Chore: PR_Comment_Notification.yml PR Comment 에 '/noti' λ₯Ό 포함할 경우 Andorid 채널 ν˜Ήμ€ Backend μ±„λ„λ‘œ λ…Έν‹°κ°€ κ°„λ‹€ * πŸŽ‰ Chore: Avatar, Content, Description μˆ˜μ • * docs: README v0.1 * CD: discord둜 apk 전달 * CD: cdλ˜λŠ”μ§€ 확인 * ci: artifact 버전 v3둜 μˆ˜μ • * test * build : λ³‘λ ¬μ²˜λ¦¬ * Revert "Merge branch 'main' into an/cd/send_to_discord" This reverts commit 925c8db99bb655c11f5f31bbf51bb6627b8741b3, reversing changes made to 346391c13691baeaf9ac17e41afd7ce98fe61f86. * ci: google-serviceμΆ”κ°€ * ci: 버저닝 label μΆ”κ°€ --- .github/actions/add_labels/action.yml | 49 +++- .../workflows/Android_Develop_PR_Builder.yml | 229 ++++++++++++++++++ .github/workflows/Android_PR_AUTO_ASSIGN.yml | 4 +- .github/workflows/Android_PR_Builder.yml | 92 ------- 4 files changed, 272 insertions(+), 102 deletions(-) create mode 100644 .github/workflows/Android_Develop_PR_Builder.yml delete mode 100644 .github/workflows/Android_PR_Builder.yml diff --git a/.github/actions/add_labels/action.yml b/.github/actions/add_labels/action.yml index d70663f8..418d1786 100644 --- a/.github/actions/add_labels/action.yml +++ b/.github/actions/add_labels/action.yml @@ -1,50 +1,81 @@ name: Add Labels Action -permissions: - contents: read - pull-requests: write +description: "Add labels to a pull request based on its title" + +inputs: + title: + description: "title of the pull request or issue" + required: true runs: using: 'composite' steps: + + - name: Input title + shell: bash + run: | + echo "Input Title: ${{ inputs.title }}" + - name: add FEAT ✨ labels uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'FEAT') }} + if: ${{ contains(inputs.title, 'FEAT') }} with: labels: | AN_FEAT ✨ - name: add UI 🎨 labels uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'UI') }} + if: ${{ contains(inputs.title, 'UI') }} with: labels: | AN_UI 🎨 - name: add REFACTOR ✍️ label uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'REFACTOR') }} + if: ${{ contains(inputs.title, 'REFACTOR') }} with: labels: | AN_REFACTOR ✍️ - name: add FIX πŸ› label uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'FIX') }} + if: ${{ contains(inputs.title, 'FIX') }} with: labels: | AN_FIX πŸ› - name: add CI/CD πŸ€– label uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'CI') || contains(github.event.pull_request.title, 'CD') }} + if: ${{ contains(inputs.title, 'CI') || contains(inputs.title, 'CD') }} with: labels: | AN_CI/CD πŸ€– - name: add CONFIG 🧭 label uses: actions-ecosystem/action-add-labels@v1 - if: ${{ contains(github.event.pull_request.title, 'CONFIG') }} + if: ${{ contains(inputs.title, 'CONFIG') }} with: labels: | AN_CONFIG 🧭 + + - name: Extract Version Name + shell: bash + env: + title: ${{ inputs.title }} + run: | + version=$(echo '${{ env.title }}' | grep -oP '\d+\.\d+\.\d+') + if [ -z "$version" ]; then + echo "No version found in the title." + echo "version=none" >> $GITHUB_ENV + else + echo "version=v$version" >> $GITHUB_ENV + fi + + - name: Add version 🏷️ label + uses: actions-ecosystem/action-add-labels@v1 + if: ${{ env.version != 'none' }} # 버전이 μ‘΄μž¬ν•  λ•Œλ§Œ μ‹€ν–‰ + with: + labels: | + ${{ env.version }} 🏷️ + + diff --git a/.github/workflows/Android_Develop_PR_Builder.yml b/.github/workflows/Android_Develop_PR_Builder.yml new file mode 100644 index 00000000..197d2b61 --- /dev/null +++ b/.github/workflows/Android_Develop_PR_Builder.yml @@ -0,0 +1,229 @@ +name: Android PR Builder + +on: + pull_request: + branches: [ an/develop ] + push: + branches: [ an/develop ] + + +defaults: + run: + working-directory: ./android + +jobs: + ktlintCheck: + name: ktLint Check + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Create Local Properties + run: touch local.properties + + - name: Access Local Properties + env: + POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }} + run: | + echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Lint Check + run: ./gradlew ktlintCheck + + testAlphaUnitTest: + name: Test Alpha Unit Test + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Create Google-Services.json + env: + GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }} + GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }} + GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} + run: | + touch ./app/src/debug/google-services.json + touch ./app/src/alpha/google-services.json + touch ./app/src/beta/google-services.json + mkdir ./app/src/release + touch ./app/src/release/google-services.json + echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json + echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json + echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json + echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json + + - name: Create Local Properties + run: touch local.properties + + - name: Access Local Properties + env: + POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }} + run: | + echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: run alpha unit test + run: ./gradlew testAlphaUnitTest + + Distribution: + name: Alpha APK to Discord + runs-on: ubuntu-latest + needs: [ ktlintCheck, testAlphaUnitTest ] + if: ${{ github.event.pull_request.merged == true }} # PR이 λ¨Έμ§€λ˜μ—ˆμ„ λ•Œλ§Œ μ‹€ν–‰ + steps: + - uses: actions/checkout@v4 + - name: Gradle cache + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} + restore-keys: | + ${{ runner.os }}-gradle- + + - name: set up JDK 17 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 17 + + - name: Create Google-Services.json + env: + GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }} + GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }} + GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} + run: | + touch ./app/src/debug/google-services.json + touch ./app/src/alpha/google-services.json + touch ./app/src/beta/google-services.json + mkdir ./app/src/release + touch ./app/src/release/google-services.json + echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json + echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json + echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json + echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json + + - name: Check google-services.json content + run: cat ./app/src/debug/google-services.json + + - name: Create Local Properties + run: touch local.properties + + - name: Access Local Properties + env: + POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }} + # POKE_RELEASE_URL: ${{ secrets.HOST_RELEASE_URI }} + # KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }} + # STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} + # KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} + # KEY_ALIAS: ${{ secrets.KEY_ALIAS }} + # STORE_FILE: ${{ secrets.STORE_FILE }} + run: | + echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties + # echo STORE_PASSWORD= $STORE_PASSWORD >> local.properties + # echo KEY_PASSWORD= $KEY_PASSWORD >> local.properties + # echo KEY_ALIAS= $KEY_ALIAS >> local.properties + # echo STORE_FILE= $STORE_FILE >> local.properties + # - name: Create Key Store + # env: + # KEY_STORE_BASE_64: ${{secrets.KEY_STORE_BASE_64}} + # run: | + # echo "$KEY_STORE_BASE_64" | base64 -d > ./funch_key_store.jks + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build alpha APK + run: ./gradlew assembleAlpha + + - name: Upload alpha APK artifact + uses: actions/upload-artifact@v4 + with: + name: android-artifact + path: android/app/build/outputs/apk/alpha/ + if-no-files-found: error + + - name: Check APK existence + run: ls -al app/build/outputs/apk/alpha/ + + - name: Extract Version Name + env: + title: ${{ github.event.pull_request.title }} + run: | + version=$(echo '${{ env.title }}' | grep -oP '\d+\.\d+\.\d+') + echo "version=v$version" >> $GITHUB_ENV + + - name: Send alpha version APK to Discord with Embeds + env: + DISCORD_WEBHOOK_URL: ${{ secrets.AlPHA_APK_DISCORD_WEB_HOOK }} + VERSION: ${{ env.version }} + PR_TITLE: ${{ github.event.pull_request.title }} + PR_URL: ${{ github.event.pull_request.html_url }} + run: | + CONTENT="μ΅œμ‹  개발 버전 APK κ°€ λ‚˜μ™”μ–΄μš”!πŸŽ‰ + [배포 버전] : $VERSION! + [ν•΄λ‹Ή PR 제λͺ©] : $PR_TITLE" + EMBED=$(jq -n \ + --arg title "PR Merged: $PR_TITLE" \ + --arg url "$PR_URL" \ + --arg description "Version: $VERSION πŸŽ‰" \ + '{ + "title": $title, + "url": $url, + "description": $description, + "color": 3066993 + }' + ) + + PAYLOAD=$(jq -n \ + --arg content "$CONTENT" \ + --argjson embeds "[$EMBED]" \ + '{ + "content": $content, + "embeds": $embeds + }' + ) + + + curl -F "payload_json=$PAYLOAD" \ + -F "file=@app/build/outputs/apk/alpha/app-alpha.apk" \ + $DISCORD_WEBHOOK_URL + diff --git a/.github/workflows/Android_PR_AUTO_ASSIGN.yml b/.github/workflows/Android_PR_AUTO_ASSIGN.yml index 09245b25..ac67694d 100644 --- a/.github/workflows/Android_PR_AUTO_ASSIGN.yml +++ b/.github/workflows/Android_PR_AUTO_ASSIGN.yml @@ -17,4 +17,6 @@ jobs: configuration-path: '.github/actions/reviewers.yml' - name: auto-add-labels ✨ - uses: ./.github/actions/add_labels \ No newline at end of file + uses: ./.github/actions/add_labels + with: + title: ${{ github.event.pull_request.title }} \ No newline at end of file diff --git a/.github/workflows/Android_PR_Builder.yml b/.github/workflows/Android_PR_Builder.yml deleted file mode 100644 index bff0c6fd..00000000 --- a/.github/workflows/Android_PR_Builder.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Android PR Builder - -on: - pull_request: - branches: [ an/develop ] - push: - branches: [ an/develop ] - -jobs: - build: - name: PR Checker - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v4 - - - name: Gradle cache - uses: actions/cache@v3 - with: - path: | - ~/.gradle/caches - ~/.gradle/wrapper - key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*') }} - restore-keys: | - ${{ runner.os }}-gradle- - - - name: set up JDK 17 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 17 - - - name: Create Google-Services.json - env: - GOOGLE_SERVICES_ALPHA: ${{ secrets.GOOGLE_SERVICES_ALPHA }} - GOOGLE_SERVICES_BETA: ${{ secrets.GOOGLE_SERVICES_BETA }} - GOOGLE_SERVICES: ${{ secrets.GOOGLE_SERVICES }} - run: | - touch ./app/src/debug/google-services.json - touch ./app/src/alpha/google-services.json - touch ./app/src/beta/google-services.json - mkdir ./app/src/release - touch ./app/src/release/google-services.json - echo $GOOGLE_SERVICES_ALPHA >> ./app/src/debug/google-services.json - echo $GOOGLE_SERVICES_ALPHA >> ./app/src/alpha/google-services.json - echo $GOOGLE_SERVICES_BETA >> ./app/src/beta/google-services.json - echo $GOOGLE_SERVICES >> ./app/src/release/google-services.json - working-directory: android - - - - name: Create Local Properties - run: touch local.properties - working-directory: android - - - name: Access Local Properties - env: - POKE_BASE_URL: ${{ secrets.POKE_BASE_URL }} - # POKE_RELEASE_URL: ${{ secrets.HOST_RELEASE_URI }} - # KEYSTORE_PATH: ${{ secrets.KEYSTORE_PATH }} - # STORE_PASSWORD: ${{ secrets.STORE_PASSWORD }} - # KEY_PASSWORD: ${{ secrets.KEY_PASSWORD }} - # KEY_ALIAS: ${{ secrets.KEY_ALIAS }} - # STORE_FILE: ${{ secrets.STORE_FILE }} - run: | - echo POKE_BASE_URL=\"${{ secrets.POKE_BASE_URL }}\" >> local.properties - # echo STORE_PASSWORD= $STORE_PASSWORD >> local.properties - # echo KEY_PASSWORD= $KEY_PASSWORD >> local.properties - # echo KEY_ALIAS= $KEY_ALIAS >> local.properties - # echo STORE_FILE= $STORE_FILE >> local.properties - working-directory: android - - # - name: Create Key Store - # env: - # KEY_STORE_BASE_64: ${{secrets.KEY_STORE_BASE_64}} - # run: | - # echo "$KEY_STORE_BASE_64" | base64 -d > ./funch_key_store.jks - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - working-directory: android - - - name: Lint Check - run: ./gradlew ktlintCheck - working-directory: android - - - name: run debug unit test - run: ./gradlew testDebugUnitTest - working-directory: android - - - name: Build debug APK - run: ./gradlew assembleDebug - working-directory: android