-
Notifications
You must be signed in to change notification settings - Fork 2
67 lines (57 loc) · 2.07 KB
/
pullrequest_build.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
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
steps:
# Checkout the Source code from the latest commit
- name: Creating .key file
run: |
echo $USERNAME
echo $CLINET_SECRET
echo $SERVER_KEY
echo $PR_NUMBER
# 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