-
Notifications
You must be signed in to change notification settings - Fork 0
122 lines (98 loc) · 5.31 KB
/
push-STG-branch.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Unique name for this workflow
name: Deploy STG branch to STG org
# Definition when the workflow should run
on:
workflow_dispatch :
push:
branches: [ STG ]
paths:
- 'force-app/**'
# Jobs to be executed
jobs:
deploy-stgbranch-to-staging-orgs:
runs-on: ubuntu-latest
if: ${{ github.actor != 'dependabot[bot]' }}
steps:
# Install Salesforce CLI
- name: 'Install Salesforce CLI'
run: |
wget https://developer.salesforce.com/media/salesforce-cli/sfdx/channels/stable/sfdx-linux-x64.tar.xz
mkdir ~/sfdx
tar xJf sfdx-linux-x64.tar.xz -C ~/sfdx --strip-components 1
echo "$HOME/sfdx/bin" >> $GITHUB_PATH
~/sfdx/bin/sfdx version
# install SFDX-Git-Delta plugin - https://github.com/scolladon/sfdx-git-delta
- name: 'Installing sfdx git delta'
run: |
echo y | sfdx plugins:install sfdx-git-delta
sfdx plugins
# Checkout the source code
- name: 'Checkout source code'
uses: actions/checkout@v2
with:
fetch-depth: 0
# - name: 'Get test class information'
# run: |
# TESTS=$(cat ./deploymentSpecificTest.txt)
# echo "APEX_TESTS=$TESTS" >> $GITHUB_ENV
- name: 'Read PR Body'
env:
# The pull request body is available through the github context object
# we put the body of the pull request in an env variable (only available to this step)
PR_BODY: ${{github.event.pull_request.body}}
# Here we print the content of the environment variable and
# pipe to a a text file.
# Then we call the local script parsePR.js, which will create
# a new file called testsToRun.txt. This file will have the list
# of tests to run separated by a comma
# Finally, we add the list of tests to the $GITHUB_ENV variable
# as this allows us to reference the list in a subsequent step. If you
# were using a normal env variable, its value would not be available outside this step.
run: |
echo $PR_BODY > ./pr_body.txt
node ./parsePR.js
TESTS=$(cat testsToRun.txt)
echo "APEX_TESTS=$TESTS" >> $GITHUB_ENV
# Store secret for STG org
- name: 'Populate auth file with SFDX_URL secret of the STG org'
shell: bash
run: |
echo ${{ secrets.SFDX_TAANA_STG}} > ./SFDX_TAANA_STG.txt
- name: 'Create delta packages for new, modified or deleted metadata'
run: |
mkdir changed-sources
sfdx sgd:source:delta --to "HEAD" --from "HEAD^" --output changed-sources/ --generate-delta --source force-app/
cat changed-sources/package/package.xml
# Now we upload the .sarif file as explained in the previous step
- name: Upload Deployment list
uses: actions/upload-artifact@v3 #github/codeql-action/upload-sarif@v2
with:
name: deploymentManifest
path: changed-sources/package/package.xml
- name: Upload destructiveChanges Deployment list if any
uses: actions/upload-artifact@v3 #github/codeql-action/upload-sarif@v2
with:
name: destructiveChangesManifest
path: changed-sources/destructiveChanges/destructiveChanges.xml
# Authenticate to org
- name: 'Authenticate to STG Org'
run: sfdx auth:sfdxurl:store -f ./SFDX_TAANA_STG.txt -s -a STG
- name: 'Deploy the changes to STG org - run specified tests'
if: ${{ env.APEX_TESTS != 'all' }}
run: |
echo ${{env.APEX_TESTS}}
sfdx force:source:deploy -p "changed-sources/force-app" --testlevel RunSpecifiedTests --runtests ${{env.APEX_TESTS}} --json
# If the env variable equals all, we run all tests
- name: 'Deploy the changes to STG org - run all tests'
if: ${{ env.APEX_TESTS == 'all' }}
run: sfdx force:source:deploy -p "changed-sources/force-app" --testlevel RunLocalTests --json
#sfdx force:source:deploy -p force-app --testlevel RunLocalTests --json
- name: 'Deploy destructive changes (if any) to Integration org'
run: sfdx force:mdapi:deploy -d "changed-sources/destructiveChanges" --ignorewarnings --testlevel RunLocalTests --json
# Authenticate to org
# - name: 'Authenticate to Staging Org to Staging org'
# run: sfdx auth:sfdxurl:store -f ./SFDX_STAGING_URL.txt -s -a staging
# - name: 'deploy the entire branch'
# run: sfdx force:source:deploy -p force-app --testlevel RunLocalTests --json
# - name: 'deploy destructive changes (if any) to Staging org'
# run: sfdx force:mdapi:deploy -d "changed-sources/destructiveChanges" --checkonly --ignorewarnings