sfdx-actions / setup-sfdx

Salesforce SFDX CLI GitHub Action
MIT License
81 stars 28 forks source link

Scratch Orgs #1

Closed brianlow closed 4 years ago

brianlow commented 4 years ago

Set the --setdefaultdevhubusername flag so that subsequent steps can create and interact with scratch orgs.

e.g.

sfdx force:auth:sfdxurl:store -f ./sfdx_auth.txt --setdefaultusername -a SFDX-ENV --setdefaultdevhubusername

Would allow:

  steps:
      - uses: sfdx-actions/cli@v1
        with:
          sfdx-auth-url: ${{ secrets.AUTH_SECRET }}
      - name: Create scratch org
        run: sfdx force:org:create -f config/project-scratch-def.json
brianlow commented 4 years ago

Workaround:

add this step immediately after sfdx-actions/cli step

      - run: sfdx force:config:set defaultdevhubusername=SFDX-ENV

Though not ideal since you need to know the SFDX-ENV alias

fechanique commented 4 years ago

done

brianlow commented 4 years ago

Thanks for the change @fechanique.

It doesn't seem to have any effect however. Still getting:

This command requires a dev hub org username set either with a flag or by default in the config.

and running sfdx force:org:list doesn't show a (D) next to the org like it normally does when the org is the default DevHub.

image

Workflow:

name: Build
on: push
jobs:
  apex:
    name: Apex Tests
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@master
      - uses: sfdx-actions/setup-sfdx@37b00269ee00294b12692c6fa19301f342369df0
        with:
          sfdx-auth-url: ${{ secrets.SFDX_AUTH_URL }}
      - run: sfdx force:org:list --all
      - run: sfdx force:org:create -f config/project-scratch-def.json
honeyverma commented 4 years ago

you can use this

sfdx force:org:create -v SFDX-ENV -f config/project-scratch-def.json -a ciScratchOrg -s --wait 10 --durationdays 1