0
0
mirror of https://github.com/TrianguloY/UrlChecker.git synced 2024-09-20 04:12:14 +02:00
UrlChecker/.github/workflows/validate-gradle-build-test.yml
2023-04-30 00:30:18 +02:00

69 lines
1.8 KiB
YAML

# This actions validates the gradle files and runs a build test to ensure the app is not corrupted
# if succeeded and the source is a pull request, builds an evaluation apk
name: Validate gradle build test
on:
push:
branches:
- master
pull_request:
branches:
- master
# parameters
env:
VARIANT: evaluation
NAME: URLCheck_evaluation.apk
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Validate Gradle wrapper
uses: gradle/wrapper-validation-action@v1
- name: Change wrapper permissions
# for some reason the gradle-build-action doesn't do this automatically
run: chmod +x ./gradlew
- name: Build & test with Gradle
uses: gradle/gradle-build-action@v2
with:
arguments: >
build
test
# the following steps will only run for PRs
- name: Generate apk
if: ${{ github.event_name == 'pull_request' }}
uses: gradle/gradle-build-action@v2
with:
arguments: >
assemble${{ env.VARIANT }}
- name: Upload apk as artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
path: ./app/build/outputs/apk/${{ env.VARIANT }}/app-${{ env.VARIANT }}.apk
name: ${{ env.NAME }}
retention-days: 14
- name: Upload PR id as artifact
if: ${{ github.event_name == 'pull_request' }}
uses: actions/upload-artifact@v3
with:
path: /dev/null
name: ${{ github.event.number }}
retention-days: 2