diff --git a/.github/workflows/android-release.yml b/.github/workflows/android-release.yml new file mode 100644 index 0000000..1d98290 --- /dev/null +++ b/.github/workflows/android-release.yml @@ -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 diff --git a/.github/workflows/app-build.yml b/.github/workflows/app-build.yml deleted file mode 100644 index f9a47d5..0000000 --- a/.github/workflows/app-build.yml +++ /dev/null @@ -1,81 +0,0 @@ -# IDEMS Template Metadata -%TAG !idems_meta! id:app_build,version:1.0.0 ---- -################################################################################## -# Configuration -################################################################################## -env: - DEPLOYMENT_NAME: "debug" - DEPLOYMENT_PRIVATE_KEY: ${{secrets.DEPLOYMENT_PRIVATE_KEY}} - FIREBASE_CONFIG: ${{secrets.FIREBASE_CONFIG}} - -################################################################################## -# Main Code -################################################################################## -name: App - Build -on: - workflow_call: - inputs: - artifact-name: - description: Name of the artifact to upload - type: string - default: www - build-flags: - description: Additional flags to pass to build command (e.g. base-href) - type: string - default: "" -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - with: - lfs: true - repository: "IDEMSInternational/parenting-app-ui.git" - ref: master - - uses: actions/checkout@v3 - with: - lfs: true - path: ".idems_app/deployments/${{env.DEPLOYMENT_NAME}}" - - name: Populate Encryption key - if: env.DEPLOYMENT_PRIVATE_KEY != '' - run: echo "${{env.DEPLOYMENT_PRIVATE_KEY}}" > ./.idems_app/deployments/${{env.DEPLOYMENT_NAME}}/encrypted/private.key - - # TODO - populate firebase as part of deployment set - - name: Populate Firebase Config - if: env.FIREBASE_CONFIG != '' - run: echo 'export const firebaseConfig = ${{env.FIREBASE_CONFIG}}' > src/environments/firebaseConfig.ts - - name: Setup Node - uses: actions/setup-node@v3 - with: - node-version: 18.x - - name: Cache node modules - uses: actions/cache@v3 - with: - path: ./.yarn/cache - # If cachebusting required (e.g. breaking yarn changes on update) change `v1` to another number - key: ${{ runner.os }}-node-modules-yarn-v1-${{ hashFiles('**/yarn.lock') }} - restore-keys: | - ${{ runner.os }}-node-modules-yarn-v1- - - - name: Install node modules - run: yarn install - - - name: Set deployment - run: yarn workflow deployment set $DEPLOYMENT_NAME - - - name: Build - run: yarn build ${{inputs.build-flags}} - - # Use github pages upload artifact action to compress and upload - - name: Upload artifact - uses: actions/upload-pages-artifact@v1.0.8 - with: - path: "www/" - name: ${{inputs.artifact-name}} -################################################################################## -# Links -################################################################################## - -# Create a reusable workflow to build deployment app -# https://colinsalmcorner.com/musings-on-reusable-workflows/ diff --git a/.github/workflows/content-sync.yml b/.github/workflows/content-sync.yml new file mode 100644 index 0000000..363ba55 --- /dev/null +++ b/.github/workflows/content-sync.yml @@ -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 diff --git a/.github/workflows/deploy-firebase.yml b/.github/workflows/deploy-firebase.yml index 97b399c..ff9cf6c 100644 --- a/.github/workflows/deploy-firebase.yml +++ b/.github/workflows/deploy-firebase.yml @@ -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]' diff --git a/.github/workflows/deploy-pr-preview.yml b/.github/workflows/deploy-pr-preview.yml new file mode 100644 index 0000000..b047773 --- /dev/null +++ b/.github/workflows/deploy-pr-preview.yml @@ -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