mirror of
https://github.com/fankes/TSBattery.git
synced 2025-09-04 17:55:30 +08:00
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Pull Request Checker
|
|
|
|
on:
|
|
pull_request:
|
|
branches: [ master ]
|
|
paths-ignore:
|
|
- '**.md'
|
|
- '**.txt'
|
|
- '.github/**'
|
|
- '!.github/workflows/**'
|
|
|
|
jobs:
|
|
build:
|
|
name: Pull Request Check
|
|
if: ${{ success() }}
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
APK_OUTPUT_PATH: 'app/build/outputs/apk'
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- name: Prepare GitHub Env
|
|
run: |
|
|
GITHUB_SHA=${{ github.sha }}
|
|
GITHUB_CI_COMMIT_ID=${GITHUB_SHA:0:7}
|
|
echo "GITHUB_CI_COMMIT_ID=$GITHUB_CI_COMMIT_ID" >> $GITHUB_ENV
|
|
- name: Setup cmake
|
|
uses: jwlawson/actions-setup-cmake@v1
|
|
with:
|
|
cmake-version: '3.22.1'
|
|
- name: Prepare Java 17
|
|
uses: actions/setup-java@v3
|
|
with:
|
|
java-version: 17
|
|
java-package: jdk
|
|
distribution: 'temurin'
|
|
cache: 'gradle'
|
|
- name: Cache Gradle Dependencies
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches
|
|
~/.gradle/wrapper
|
|
!~/.gradle/caches/build-cache-*
|
|
key: gradle-deps-core-${{ hashFiles('**/build.gradle.kts') }}
|
|
restore-keys: |
|
|
gradle-deps
|
|
- name: Cache Gradle Build
|
|
uses: actions/cache@v3
|
|
with:
|
|
path: |
|
|
~/.gradle/caches/build-cache-*
|
|
key: gradle-builds-core-${{ github.sha }}
|
|
restore-keys: |
|
|
gradle-builds
|
|
- name: Build with Gradle
|
|
run: |
|
|
./gradlew :app:assembleDebug
|
|
./gradlew :app:assembleRelease
|
|
echo "DEBUG_APK_PATH=$(find ${{ env.APK_OUTPUT_PATH }}/debug -name '*.apk')" >> $GITHUB_ENV
|
|
echo "RELEASE_APK_PATH=$(find ${{ env.APK_OUTPUT_PATH }}/release -name '*.apk')" >> $GITHUB_ENV
|
|
- name: Upload Artifacts (Debug)
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
path: ${{ env.DEBUG_APK_PATH }}
|
|
name: TSBattery-debug-${{ github.event.head_commit.id }}
|
|
- name: Upload Artifacts (Release)
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
path: ${{ env.RELEASE_APK_PATH }}
|
|
name: TSBattery-release-${{ github.event.head_commit.id }} |