Skip to content

Commit

Permalink
Updated workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisMarsh82 committed Feb 20, 2024
1 parent 517c825 commit 638b09b
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 193 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/android-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
##################################################################################
# Calls workflow from code repo
##################################################################################
name: Android - Release to Google Play

on:
workflow_dispatch:

jobs:
android_release:
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-android-release.yml@master
secrets: inherit
81 changes: 0 additions & 81 deletions .github/workflows/app-build.yml

This file was deleted.

23 changes: 23 additions & 0 deletions .github/workflows/content-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
##################################################################################
# Calls workflow from code repo
##################################################################################
name: Perform content sync and create a PR

on:
workflow_dispatch:
inputs:
pr-title:
description: Title for PR
type: string
default: sync content from google sheets
pr-body:
description: Description for PR
type: string
default: Automated PR creation from actions
jobs:
sync_content:
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-content-sync.yml@master
with:
pr-title: ${{ inputs.pr-title }}
pr-body: ${{ inputs.pr-body }}
secrets: inherit
116 changes: 4 additions & 112 deletions .github/workflows/deploy-firebase.yml
Original file line number Diff line number Diff line change
@@ -1,123 +1,15 @@
# IDEMS Template Metadata
%TAG !idems_meta! id:deploy_firebase,version:1.0.0
---
##################################################################################
# About
##################################################################################
# Build and deploy app to firebase
# Supports deploying to custom hosting channel for long-lived preview urls (30d)
# Or using custom hosting target

##################################################################################
# Configuration (updated per deployment)
# Calls workflow from code repo
##################################################################################
name: Deploy - Firebase

env:
FIREBASE_PROJECT_ID: "plh-teens-app1" # | ID of firebase project used (in case of multiple deployment targets just specify default)
FIREBASE_HOSTING_CHANNEL: "live" # | Name of channel to deploy to (default 'live' is main site, any other word, e.g. 'pr' will create random temp preview site)
FIREBASE_HOSTING_TARGET: "idems-debug" # | Optional override if using multiple hosting target sites (default target project ID)
FIREBASE_SERVICE_ACCOUNT: ${{secrets.FIREBASE_SERVICE_ACCOUNT}} # | JSON export of firebase service account (from console)
##################################################################################
# Triggers
# Specify conditions to run workflow. # See more information at:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows
##################################################################################
on:
push:
branches:
- "main"

##################################################################################
# Main Code
##################################################################################
name: Deploy - Firebase
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
concurrency:
group: "deploy_firebase"
cancel-in-progress: true

jobs:
build_action:
uses: ./.github/workflows/app-build.yml
with:
artifact-name: www
web_preview:
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-deploy-web-preview.yml@master
secrets: inherit

deploy:
needs: build_action
runs-on: ubuntu-latest
outputs:
urls: ${{ steps.deploy.outputs.urls }}
steps:
# Extract build artifact
- uses: actions/checkout@v3
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: www
- name: Extract Build folder
run: |
mkdir www
tar -xf artifact.tar --directory www
# Ensure FIREBASE_HOSTING_TARGET set (default fallback to projectId)
- name: Populate Env
if: ${{env.FIREBASE_HOSTING_TARGET == ''}}
run: echo "FIREBASE_HOSTING_TARGET=${{env.FIREBASE_PROJECT_ID}}" >> "$GITHUB_ENV"

# Create a .firebaserc file mapping any firebase deployment host targets (required if multi-host projects)
# e.g. {"projects": {"default": "my_app"},"targets": {"my_app": {"hosting": {"my_app_dev":["my_app_dev"]} } }
- name: Populate Firebase Targets
run: |
FIREBASE_RC_TARGETS=$(jq -n \
--argjson "${{env.FIREBASE_PROJECT_ID}}" \
'{"hosting":{"${{env.FIREBASE_HOSTING_TARGET}}":["${{env.FIREBASE_HOSTING_TARGET}}"]}}' \
'$ARGS.named'
)
FIREBASE_RC=$(jq -n \
--argjson projects '{"default":"${{env.FIREBASE_PROJECT_ID}}"}' \
--argjson targets "$FIREBASE_RC_TARGETS" \
'$ARGS.named'
)
echo $FIREBASE_RC | jq '.'
echo $FIREBASE_RC > .firebaserc
# Create a firebase.json file to handle single-page-app hosting redirects
# e.g. {"hosting": [{"target": "app","public": "www","ignore": ["firebase.json"], "rewrites": [{"source": "**","destination": "/index.html"}] }]}
- name: Populate Firebase JSON
run: |
FIREBASE_JSON_HOSTING=$(jq -n \
--arg target "${{ env.FIREBASE_HOSTING_TARGET }}" \
--arg public "www" \
--argjson ignore '["firebase.json"]' \
--argjson rewrites '[{"source": "**","destination": "/index.html"}]' \
'$ARGS.named'
)
FIREBASE_JSON=$(jq -n \
--argjson hosting "[$FIREBASE_JSON_HOSTING]" \
'$ARGS.named'
)
echo $FIREBASE_JSON | jq '.'
echo $FIREBASE_JSON > firebase.json
# Deploy to firebase
- id: deploy
uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ env.FIREBASE_SERVICE_ACCOUNT }}"
projectId: "${{ env.FIREBASE_PROJECT_ID }}"
channelId: "${{ env.FIREBASE_HOSTING_CHANNEL }}"
target: "${{ env.FIREBASE_HOSTING_TARGET }}"
expires: "30d"
##################################################################################
# Useful Links
##################################################################################
# https://firebase.google.com/docs/hosting/full-config
# https://firebase.google.com/docs/cli/targets

# https://www.baeldung.com/linux/jq-command-json
# https://jqlang.github.io/jq/manual/
# https://jqplay.org/

# echo $FIREBASE_JSON | jq '.hosting[0]'
13 changes: 13 additions & 0 deletions .github/workflows/deploy-pr-preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
##################################################################################
# Calls workflow from code repo
##################################################################################
name: Deployment Preview

on:
pull_request:
types: [labeled, synchronize]

jobs:
pr_preview:
uses: IDEMSInternational/parenting-app-ui/.github/workflows/reusable-deploy-pr-preview.yml@master
secrets: inherit

0 comments on commit 638b09b

Please sign in to comment.