|
| 1 | +name: ci |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + paths-ignore: |
| 6 | + - '**.md' |
| 7 | + pull_request: |
| 8 | + paths-ignore: |
| 9 | + - '**.md' |
| 10 | + workflow_dispatch: |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: environment-${{ github.ref }} |
| 14 | + cancel-in-progress: true |
| 15 | + |
| 16 | +jobs: |
| 17 | + job-common: |
| 18 | + runs-on: ubuntu-24.04 |
| 19 | + outputs: |
| 20 | + SHORT_SHA: ${{ steps.expose_sha.outputs.short_sha }} |
| 21 | + steps: |
| 22 | + - name: expose short commit sha |
| 23 | + id: expose_sha |
| 24 | + run: | |
| 25 | + SHORT_SHA=${GITHUB_SHA::7} |
| 26 | + echo "short_sha=$SHORT_SHA" >> $GITHUB_ENV |
| 27 | + echo "SHORT_SHA=$SHORT_SHA" >> $GITHUB_OUTPUT |
| 28 | +
|
| 29 | + build-android: |
| 30 | + needs: job-common |
| 31 | + runs-on: ubuntu-24.04 |
| 32 | + timeout-minutes: 60 |
| 33 | + env: |
| 34 | + SHORT_SHA: ${{ needs.job-common.outputs.SHORT_SHA }} |
| 35 | + FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true |
| 36 | + steps: |
| 37 | + - name: checkout repo |
| 38 | + uses: actions/checkout@v5 |
| 39 | + with: |
| 40 | + fetch-depth: 0 |
| 41 | + |
| 42 | + - name: setup jdk 21 |
| 43 | + uses: actions/setup-java@v5 |
| 44 | + with: |
| 45 | + distribution: 'temurin' |
| 46 | + java-version: '21' |
| 47 | + |
| 48 | + - name: cache gradle dependencies |
| 49 | + uses: actions/cache@v5 |
| 50 | + with: |
| 51 | + path: ~/.gradle/caches |
| 52 | + key: gradle-${{ runner.os }}-${{ hashFiles('/*.gradle*', '/gradle-wrapper.properties') }} |
| 53 | + restore-keys: | |
| 54 | + gradle-${{ runner.os }}- |
| 55 | +
|
| 56 | + - name: cache gradle wrapper |
| 57 | + uses: actions/cache@v5 |
| 58 | + with: |
| 59 | + path: ~/.gradle/wrapper |
| 60 | + key: gradle-wrapper-${{ runner.os }}-${{ hashFiles('**/gradle/wrapper/gradle-wrapper.properties') }} |
| 61 | + |
| 62 | + - name: clean outputs directory |
| 63 | + run: rm -rf app/build/outputs/* |
| 64 | + |
| 65 | + - name: make gradlew executable |
| 66 | + run: chmod +x ./gradlew |
| 67 | + |
| 68 | + - name: assemble debug artifact |
| 69 | + run: ./gradlew assembleDebug |
| 70 | + |
| 71 | + - name: upload artifacts to outputs |
| 72 | + uses: actions/upload-artifact@v6 |
| 73 | + with: |
| 74 | + path: | |
| 75 | + app/build/outputs/apk |
| 76 | +
|
| 77 | + - name: expose version |
| 78 | + id: version |
| 79 | + run: ./gradlew -q printVersion | tee -a $GITHUB_ENV | tee -a $GITHUB_OUTPUT |
| 80 | + |
| 81 | + - name: expose apk path |
| 82 | + run: | |
| 83 | + echo "APK_PATH=$(find app/build/outputs/apk -name '*.apk' -type f -printf '%T@ %p\n' | sort -n | tail -1 | cut -d' ' -f2)" >> $GITHUB_ENV |
| 84 | +
|
| 85 | + - name: telegram notify |
| 86 | + env: |
| 87 | + TELEGRAM_TOKEN: ${{ secrets.TELEGRAM_TOKEN }} |
| 88 | + CHAT_ID: ${{ secrets.TELEGRAM_CHAT_ID }} |
| 89 | + THREAD_ID: ${{ secrets.TELEGRAM_THREAD_ID }} |
| 90 | + MESSAGE: | |
| 91 | + ✅ *${{ env.VERSION_NAME }} (${{ env.VERSION_CODE }})* |
| 92 | + *Repo:* [${{ github.repository }}](${{ github.server_url }}/${{ github.repository }}) |
| 93 | + *Branch:* [${{ github.ref_name }}](${{ github.server_url }}/${{ github.repository }}/tree/${{ github.ref_name }}) |
| 94 | + *Commit:* [${{ env.SHORT_SHA }}](${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}) |
| 95 | + run: | |
| 96 | + curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendDocument" \ |
| 97 | + -F chat_id="${CHAT_ID}" \ |
| 98 | + -F document="@${{ env.APK_PATH }}" \ |
| 99 | + -F caption="${{ env.MESSAGE }}" \ |
| 100 | + -F message_thread_id="${THREAD_ID}" \ |
| 101 | + -F parse_mode="Markdown" |
0 commit comments