Skip to content

Create Scratch Org 🔔 #141

Create Scratch Org 🔔

Create Scratch Org 🔔 #141

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: false
runApexTests:
type: boolean
description: 'Run Apex Tests?'
default: true
branches:
- main
- develop
# Jobs
jobs:
spin-up-scratch-org:
runs-on: ubuntu-latest
env:
DEV_HUB_AUTH_URL: ${{ secrets.DEV_HUB_AUTH_URL }}
SF_ADMIN_EMAIL: ${{ github.event.inputs.adminEmail }}
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: 'Upload Scratch Org Credentials as Artifact'
uses: actions/upload-artifact@v4
with:
name: minlopro-scratch-org-credentials
path: |
build/*-SO.json
build/.env
if-no-files-found: error
retention-days: 5
- name: 'Run Apex Tests With Coverage'
if: ${{ success() && github.event.inputs.runApexTests == 'true' }}
run: npm run sf:apex:tests:coverage -- --target-org "ScratchOrg"
- name: 'Purge Scratch Org'
if: ${{ github.event.inputs.purgeOnCreate == 'true' }}
run: sf org delete scratch --target-org "ScratchOrg" --no-prompt