|
| 1 | +name: Android CI |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ "**" ] |
| 6 | + paths-ignore: |
| 7 | + - '**/*.md' |
| 8 | + pull_request: |
| 9 | + branches: [ "**" ] |
| 10 | + paths-ignore: |
| 11 | + - '**/*.md' |
| 12 | + workflow_dispatch: |
| 13 | + |
| 14 | +jobs: |
| 15 | + init: |
| 16 | + name: Init |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - name: Checkout code |
| 20 | + uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: notify telegram |
| 23 | + uses: EverythingSuckz/github-telegram-notify@main |
| 24 | + continue-on-error: true |
| 25 | + with: |
| 26 | + bot_token: ${{ secrets.bot_token }} |
| 27 | + chat_id: -1002951791106 |
| 28 | + topic_id: 4 |
| 29 | + |
| 30 | + build_debug_apk: |
| 31 | + name: Build App Debug APK |
| 32 | + runs-on: ubuntu-latest |
| 33 | + |
| 34 | + steps: |
| 35 | + - name: Check out repository |
| 36 | + uses: actions/checkout@v4 |
| 37 | + |
| 38 | + - name: Set up JDK 17 |
| 39 | + uses: actions/setup-java@v4 |
| 40 | + with: |
| 41 | + java-version: '17' |
| 42 | + distribution: 'oracle' |
| 43 | + cache: gradle |
| 44 | + |
| 45 | + - name: Grant execute permission for gradlew |
| 46 | + run: chmod +x gradlew |
| 47 | + |
| 48 | + - name: Validate Gradle wrapper |
| 49 | + uses: gradle/actions/wrapper-validation@v4 |
| 50 | + |
| 51 | + - name: Build with Gradle |
| 52 | + id: gradle_build_debug |
| 53 | + env : |
| 54 | + BOT_TOKEN: ${{ secrets.bot_token }} |
| 55 | + CHAT_ID: ${{ secrets.chat_id }} |
| 56 | + run: ./gradlew assembleDebug |
| 57 | + |
| 58 | + - name: Upload debug apk |
| 59 | + uses: actions/upload-artifact@v4 |
| 60 | + with: |
| 61 | + name: app-debug |
| 62 | + path: app/build/outputs/apk/debug/app-debug.apk |
| 63 | + |
| 64 | + send_debug_apk: |
| 65 | + name: Send Debug APK |
| 66 | + runs-on: ubuntu-latest |
| 67 | + needs: build_debug_apk |
| 68 | + |
| 69 | + steps: |
| 70 | + - name: Check out repository |
| 71 | + uses: actions/checkout@v4 |
| 72 | + with: |
| 73 | + ref: ${{ github.event.pull_request.head.ref }} |
| 74 | + |
| 75 | + - name: Download debug apk |
| 76 | + uses: actions/download-artifact@v4 |
| 77 | + with: |
| 78 | + name: app-debug |
| 79 | + |
| 80 | + - name: List repo contents |
| 81 | + run: ls |
| 82 | + |
| 83 | + - name: Get the last commit message |
| 84 | + id: get_commit_msg |
| 85 | + run: | |
| 86 | + commit_message=$(git log -1 --pretty=format:'%s') |
| 87 | + echo "message=$commit_message" >> $GITHUB_OUTPUT |
| 88 | + |
| 89 | + - name: Rename file |
| 90 | + run: | |
| 91 | + mv app-debug.apk xsigner-app-debug.apk |
| 92 | + ls |
| 93 | +
|
| 94 | + - name: Send APK to Debug Channel Telegram with Topic ID |
| 95 | + if: success() |
| 96 | + continue-on-error: true |
| 97 | + run: | |
| 98 | + curl -X POST "https://api.telegram.org/bot${{ secrets.bot_token }}/sendDocument" \ |
| 99 | + -F chat_id="-1002295019134" \ |
| 100 | + -F message_thread_id="10" \ |
| 101 | + -F document=@"xsigner-app-debug.apk" \ |
| 102 | + -F caption="${{ github.event.head_commit.message }} by ${{ github.actor }}" |
0 commit comments