Create Scratch Org 🔔 #162
Workflow file for this run
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
name: Create Scratch Org 🔔 | |
# Trigger Events | |
on: | |
workflow_dispatch: | |
inputs: | |
adminEmail: | |
type: string | |
description: "Admin Email Address" | |
required: true | |
purgeOnCreate: | |
type: boolean | |
description: 'Purge On Create?' | |
default: true | |
runApexTests: | |
type: boolean | |
description: 'Run Apex Tests?' | |
default: true | |
branches: | |
- main | |
- develop | |
# Jobs | |
jobs: | |
spin-up-scratch-org: | |
runs-on: ubuntu-latest | |
environment: "Minlopro DevHub" | |
env: | |
# This env variable does not have 'SF_' prefix which excludes it from '.env' file | |
DEV_HUB_AUTH_URL: ${{ secrets.SF_AUTH_URL }} | |
SF_ADMIN_EMAIL: ${{ github.event.inputs.adminEmail }} | |
SF_GITHUB_WEBHOOK_SECRET: ${{ secrets.SF_GITHUB_WEBHOOK_SECRET }} | |
SF_GOOGLE_API_KEY: ${{ secrets.SF_GOOGLE_API_KEY }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: '20.x' | |
- name: 'Install Salesforce CLI & Authorize DevHub Org' | |
run: | | |
bash ./scripts/deploy/build.sh | |
bash ./scripts/deploy/authorize_org.sh --sfdxUrl "$DEV_HUB_AUTH_URL" --orgAlias "DevHub" | |
sf config set target-dev-hub=DevHub | |
- name: 'Spin Up Brand New Scratch Org' | |
continue-on-error: true | |
run: | | |
inputsFile="inputs.txt" | |
touch $inputsFile | |
# Dev Hub Alias | |
echo "DevHub" >> $inputsFile | |
# Scratch Org Alias | |
echo "ScratchOrg" >> $inputsFile | |
# Admin Email Address | |
echo "${{github.event.inputs.adminEmail}}" >> $inputsFile | |
# Initiate scratch org generation | |
bash ./scripts/automations/create_scratch_org.sh < $inputsFile | |
- name: 'Run Apex Tests With Coverage' | |
continue-on-error: true | |
if: ${{ github.event.inputs.runApexTests == 'true' }} | |
run: npm run sf:apex:tests:coverage -- --target-org "ScratchOrg" | |
- name: 'Upload Scratch Org Credentials as Artifact' | |
continue-on-error: true | |
uses: actions/upload-artifact@v4 | |
with: | |
name: minlopro-scratch-org-credentials | |
path: | | |
build/*-SO.json | |
build/.env | |
if-no-files-found: error | |
include-hidden-files: true | |
retention-days: 5 | |
- name: 'Purge Scratch Org' | |
if: ${{ always() && github.event.inputs.purgeOnCreate == 'true' }} | |
run: sf org delete scratch --target-org "ScratchOrg" --no-prompt |