Publish demo nightly #73
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run nightly every nights at midnight or when triggered manually | |
# https://github.com/orgs/community/discussions/27128 | |
name: Publish demo nightly | |
on: | |
workflow_dispatch: | |
inputs: | |
version_name: | |
description: 'Version name as x.y.z-optional' | |
required: true | |
type: string | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
check_date: | |
runs-on: ubuntu-latest | |
name: Check latest commit | |
outputs: | |
should_run: ${{ steps.should_run.outputs.should_run }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Print the last commit sha | |
run: echo ${{ github.sha }} | |
- id: should_run | |
name: Check that the last commit was made in the last 24h | |
if: ${{ github.event_name == 'schedule' }} | |
run: | | |
new_commits=$(git log --since="24 hours ago" --oneline) | |
if [[ -n "$new_commits" ]]; then | |
echo "should_run=true" >> "$GITHUB_OUTPUT" | |
else | |
echo "should_run=false" >> "$GITHUB_OUTPUT" | |
fi | |
Build-nightly: | |
needs: check_date | |
if: ${{ needs.check_date.outputs.should_run != 'false' }} | |
runs-on: ubuntu-latest | |
env: | |
DEMO_KEY_PASSWORD: ${{ secrets.DEMO_KEY_PASSWORD }} | |
USERNAME: ${{ github.actor }} | |
GITHUB_TOKEN: ${{ github.token }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Required due to the way Git works, without it this action won't be able to find any or the correct tags | |
- name: Setup VERSION_NAME from inputs | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: echo "VERSION_NAME=${{ inputs.version_name }}" >> "$GITHUB_ENV" | |
- name: Find the latest tag | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
id: previoustag | |
uses: "WyriHaximus/github-action-get-previous-tag@v1" | |
with: | |
fallback: 0.0.1-alpha01 # Optional fallback tag to use when no tag can be found | |
- name: Setup VERSION_NAME from the latest tag | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
run: echo "VERSION_NAME=${{ steps.previoustag.outputs.tag }}" >> "$GITHUB_ENV" | |
- name: Print VersionName | |
run: | | |
echo "Version name is ${{ env.VERSION_NAME }}" | |
echo "GitHub ref ${GITHUB_REF}" | |
echo "GitHub ref name ${GITHUB_REF_NAME}" | |
echo "GitHub ref type ${GITHUB_REF_TYPE}" | |
echo "CI ${{ env.CI }}" | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- uses: gradle/wrapper-validation-action@v1 | |
- uses: gradle/gradle-build-action@v2 | |
- name: Assemble nightly release | |
run: ./gradlew assembleNightlyRelease | |
- name: Upload artifact to Firebase App Distribution | |
uses: wzieba/Firebase-Distribution-Github-Action@v1 | |
with: | |
appId: ${{ secrets.NIGHTLY_APP_ID }} | |
serviceCredentialsFileContent: ${{ secrets.FIREBASE_CREDENTIAL_FILE_CONTENT }} | |
groups: ${{ secrets.NIGHTLY_GROUPS }} | |
file: pillarbox-demo/build/outputs/apk/nightly/release/pillarbox-demo-nightly-release.apk |