Skip to content

Checks running whenever new PR is created #125

Checks running whenever new PR is created

Checks running whenever new PR is created #125

name: PR Checks
run-name: Checks running whenever new PR is created
on:
pull_request:
branches:
- dev
- main
paths-ignore:
- 'docs/*'
- '.github/workflows/*'
jobs:
build:
runs-on: ubuntu-latest
container: salesforce/cli:latest-slim
env:
USERNAME: ${{ secrets.SF_CICD_USERNAME }}
CLINET_SECRET: ${{ secrets.SF_CLIENT_SECRET }}
SERVER_KEY: ${{ secrets.SF_CICD_SERVERKEY }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
# Checkout the Source code from the latest commit
- uses: actions/checkout@v3
with:
fetch-depth: 0
# Installing NPM so that SFDX can be installed
# - name: Installing NPM
# run: |
# npm install
# Installing SFDX CLI
# - name: Installing SFDX CLI
# run: |
# npm install @salesforce/cli --global
# Creating new .key for .crt file stored in the Connected App
- name: Creating .key file
run: |
touch server.key
echo -e "$SERVER_KEY" >> server.key
# Authorizing to DevHub
- name: Authorizing the DevHub
run: sf org login jwt --json --alias DevHub --set-default --set-default-dev-hub --username "$USERNAME" --jwt-key-file server.key --client-id $CLINET_SECRET
# Creating a Scratch Org using the pull request number
- name: Creating a Scratch Org
run: sf org create scratch --target-dev-hub DevHub --name build_$PR_NUMBER --definition-file config/project-scratch-def.json --set-default --duration-days 1
# Pushing source to the Scratch Org
- name: Pushing source and metadata to the Scratch Org
run: sf project deploy start
# Executing all unit tests
- name: Run unit tests
run: sf apex run test --wait 30 --test-level RunAllTestsInOrg --code-coverage