Skip to content

Deploy to Firebase Beta #18

Deploy to Firebase Beta

Deploy to Firebase Beta #18

name: Deploy to Firebase Beta
on:
workflow_dispatch:
inputs:
branch:
description: "Branch name to build and deploy from"
required: true
type: string
default: master
group:
description: "Tester group to deploy to"
required: true
type: choice
options:
- Greenstand
- dev
- debug
default: Greenstand
release_notes:
description: "Release Notes"
required: true
type: string
jobs:
bump-version:
name: Bump version code
runs-on: ubuntu-latest
outputs:
version_code: ${{ steps.bump.outputs.version_code }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
fetch-depth: 0
token: ${{ secrets.ADMIN_PAT }}
- name: Bump version code
id: bump
uses: ./.github/workflows/actions/bump-version
with:
branch: ${{ inputs.branch }}
build:
name: Build beta APK
needs: bump-version
uses: ./.github/workflows/build.yml
with:
build_variant: beta
source_ref: ${{ inputs.branch }}
upload_artifact: true
secrets: inherit
deploy:
name: Deploy to Firebase
runs-on: ubuntu-latest
needs: [bump-version, build]
if: ${{ github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.branch }}
- name: Download APK artifact
uses: actions/download-artifact@v4
with:
name: app-beta
- name: Resolve APK path
id: resolve-apk
shell: bash
run: |
APK_FILE=$(find . -maxdepth 3 -type f -name "*.apk" | head -n 1)
if [ -z "$APK_FILE" ]; then
echo "No APK found after artifact download."
find . -maxdepth 4 -type f
exit 1
fi
echo "apk_file=$APK_FILE" >> "$GITHUB_OUTPUT"
echo "Using APK: $APK_FILE"
- name: Validate Firebase service account secret
run: |
if [ -z "${{ secrets.FIREBASE_SERVICE_ACCOUNT }}" ]; then
echo "FIREBASE_SERVICE_ACCOUNT is not set. Add the Firebase service account JSON in repository secrets."
exit 1
fi
- name: Deploy to Firebase App Distribution
uses: wzieba/Firebase-Distribution-Github-Action@v1
with:
appId: 1:422699885542:android:aab16ef8fc4e5968a0ec27
serviceCredentialsFileContent: ${{ secrets.FIREBASE_SERVICE_ACCOUNT }}
groups: ${{ inputs.group }}
releaseNotes: ${{ github.event.inputs.release_notes }}
file: ${{ steps.resolve-apk.outputs.apk_file }}
# notify:
# name: Send Slack notifications
# runs-on: ubuntu-latest
# needs: [bump-version, deploy]
# if: success()
#
# steps:
# - name: Get git branch
# id: git-branch
# run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
#
# - name: Send Slack notification (main)
# uses: slackapi/slack-github-action@v1
# with:
# payload: |
# {
# "text": "A new Greenstand Beta Build has been released on Firebase",
# "blocks": [
# {
# "type": "section",
# "text": {
# "type": "mrkdwn",
# "text": "A new Greenstand Beta Build has been released on Firebase\n*Build Number:* ${{ needs.bump-version.outputs.version_code }}\n*Branch:* ${{ steps.git-branch.outputs.branch }}"
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_URL }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
#
# - name: Send Slack notification (QC)
# uses: slackapi/slack-github-action@v1
# with:
# payload: |
# {
# "text": "A new Greenstand Beta Build has been released on Firebase",
# "blocks": [
# {
# "type": "section",
# "text": {
# "type": "mrkdwn",
# "text": "A new Greenstand Beta Build has been released on Firebase\n*Build Number:* ${{ needs.bump-version.outputs.version_code }}\n*Branch:* ${{ steps.git-branch.outputs.branch }}"
# }
# }
# ]
# }
# env:
# SLACK_WEBHOOK_URL: ${{ secrets.SLACK_URL_QC }}
# SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK