Skip to content

svierk/sfdx-create-scratch-org

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

🌩️ SFDX Create Scratch Org

This repository implements a simple GitHub composite action for creating Salesforce scratch orgs.

Usage

In a GitHub workflow, the use of the action after installing the SF CLI and authorizing the respective DevHub Org could look like this:

jobs:
  create-scratch-org:
    name: Create Scratch Org
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@main
        with:
          fetch-depth: 0

      - name: Select Node Version
        uses: svierk/get-node-version@main

      - name: Install SF CLI
        uses: svierk/sfdx-cli-setup@main

      - name: Authorize DevHub
        uses: svierk/sfdx-login@main
        with:
          client-id: ${{ secrets.SFDX_CONSUMER_KEY }}
          jwt-secret-key: ${{ secrets.SFDX_JWT_SECRET_KEY }}
          username: ${{ secrets.SFDX_USERNAME }}
          set-default: true
          set-default-dev-hub: true
          alias: devhub

      - name: Create Scratch Org
        uses: svierk/sfdx-create-scratch-org@main
        with:
          alias: scratch-${{ github.run_id }}
          name: ${{ inputs.name }}
          description: ${{ inputs.description }}
          admin-email: ${{ inputs.email }}
          set-default: true
          definition-file: config/project-scratch-def.json
          target-dev-hub: devhub
          duration-days: ${{ inputs.lifespan }}
          wait: 10

      - name: Package Installation
        if: ${{ inputs.install-packages }}
        uses: svierk/sfdx-package-installation@main
        with:
          packages: ${{ inputs.packages }}
          wait: 30
          publish-wait: 20

      - name: Deploy Metadata
        if: ${{ inputs.deploy-metadata }}
        run: sf project deploy start

      - name: Generate Password
        run: sf org generate password --target-org scratch-${{ github.run_id }}

The following actions were also used in the example workflow above:

Of course, the create scratch org action can be used flexibly and the respective approach can vary.

References

The scratch org creation option supported by this GitHub composite action can be found in the Salesforce CLI Command Reference here:

More details can be found in the related Salesforce DX Developer Guide: Create Scratch Orgs

Releases

Latest release notes can be found on the release page.

License

The scripts and documentation in this project are released under the MIT License.