From 77ad8cb501c9687f37286ba7cc5bc2e03c8b16f2 Mon Sep 17 00:00:00 2001 From: Lincoln Rychecky Date: Wed, 21 Aug 2024 14:47:13 -0600 Subject: [PATCH] workflow updates --- .github/workflows/apex-tests-pr.yml | 38 ++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/.github/workflows/apex-tests-pr.yml b/.github/workflows/apex-tests-pr.yml index 1c8d39f..dc495c8 100644 --- a/.github/workflows/apex-tests-pr.yml +++ b/.github/workflows/apex-tests-pr.yml @@ -1,28 +1,44 @@ name: Salesforce CI on: - push: - branches: - - main - pull_request: - branches: - - main + workflow_dispatch: + inputs: + branch: + description: "Branch to run the tests on" + required: true + default: "main" jobs: build: runs-on: ubuntu-latest steps: + - uses: actions/setup-node@v1 + with: + node-version: "21.x" + + - name: Install Salesforce CLI + run: | + npm install sfdx-cli + node_modules/sfdx-cli/bin/run --version + node_modules/sfdx-cli/bin/run plugins --core + - name: Checkout repository uses: actions/checkout@v2 - - name: Install Salesforce CLI - uses: forcedotcom/sfdx-action@v1 - with: - version: latest + # Store Secret for debhub + - name: Populate auth file with DEVHUB_SFDX_URL secrets + shell: bash + run: | + echo ${{ secrets.DEVHUB_SFDX_URL }} > ./DEVHUB_SFDX_URL.txt + secretFileSize=$(wc -c "./DEVHUB_SFDX_URL.txt" | awk '{print $1}') + if [ $secretFileSize == 1 ]; then + echo "DEVHUB_SFDX_URL secret is empty or not set. Is this workflow running on a fork? Exiting..."; + exit 1; + fi - name: Authenticate to Dev Hub - run: sfdx auth:jwt:grant --clientid ${{ secrets.SF_CLIENT_ID }} --jwtkeyfile assets/server.key --username ${{ secrets.SF_DEV_HUB_USERNAME }} --instanceurl https://login.salesforce.com --setdefaultdevhubusername + run: sfdx auth:sfdxurl:store -f ./DEVHUB_SFDX_URL.txt -a devhub -d - name: Create Scratch Org run: sfdx force:org:create -s -f config/project-scratch-def.json -a MyScratchOrg