Implementing Unit Test automation #2
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: Salesforce CI/CD | |
on: | |
pull_request: | |
branches: | |
- '**' | |
workflow_dispatch: | |
jobs: | |
build-and-deploy: | |
runs-on: ubuntu-latest | |
env: | |
PBO_AUTH_URL: ${{ secrets.PBO_AUTH_URL }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install Salesforce CLI | |
run: npm install @salesforce/cli --global | |
- name: debug only - printing secret | |
run: echo ${PBO_AUTH_URL} | |
- name: Create authentication file from secret | |
run: echo ${PBO_AUTH_URL} > secret.json | |
- name: Authenticate to Dev Hub | |
run: sf org login sfdx-url -f secret.json --set-default-dev-hub | |
- name: Create Scratch Org | |
run: sf org create scratch -f config/project-scratch-def.json --set-default --alias ScratchOrg --no-namespace -y 1 | |
- name: Push source to Scratch Org | |
run: sf project deploy start --target-org ScratchOrg | |
- name: Run Apex tests | |
run: sf apex run test --target-org ScratchOrg --result-format tap --output-dir test-results --code-coverage | |
- name: Generate Code Coverage Report | |
run: sf apex test report --result-dir test-results --code-coverage | |
- name: Delete Scratch Org | |
if: always() | |
run: sf org delete scratch --target-org ScratchOrg --no-prompt |