-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (107 loc) · 5.85 KB
/
staging.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
123
124
125
126
127
128
# This is a basic workflow to help you get started with Actions
name: 'Push request check'
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the master branch
push:
branches: [ preproduction, fullcopy, devops,devops-new ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Get banch name (Merge)
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
shell: bash
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
# Print
- name: Debug
run: echo ${{ env.BRANCH_NAME }}
# wget https://developer.salesforce.com/media/salesforce-cli/sfdx-linux-amd64.tar.xz
# mkdir sfdx-cli
# tar xJf sfdx-linux-amd64.tar.xz -C sfdx-cli --strip-components 1
# ./sfdx-cli/install
# Install Salesforce CLI
- name: 'Build and Deploy'
run: |
sudo npm install sfdx-cli --global
# Decrypt file
- name: 'Decrypt file'
run: openssl enc -nosalt -aes-256-cbc -d -in assets/server.key.enc -out server.key -base64 -K ${{secrets.DECRYPTION_KEY}} -iv ${{secrets.DECRYPTION_IV}}
# Authorize devops
- name: 'Authorize devops'
if: ${{ env.BRANCH_NAME == 'devops' }}
run: sfdx auth:jwt:grant --clientid=${{secrets.PRODUCTION_CONSUMER_KEY}} --username=${{secrets.PARTIALDEV_USERNAME}} --instanceurl=${{secrets.SFDC_LOGIN_SANDBOX_URL}} --jwtkeyfile server.key --setdefaultdevhubusername --setalias=hub-org
# Authorize devops-new
- name: 'Authorize devops-new'
if: ${{ env.BRANCH_NAME == 'devops-new' }}
run: sfdx auth:jwt:grant --clientid=${{secrets.PRODUCTION_CONSUMER_KEY}} --username=${{secrets.PARTIALDEV_USERNAME}} --instanceurl=${{secrets.SFDC_LOGIN_SANDBOX_URL}} --jwtkeyfile server.key --setdefaultdevhubusername --setalias=hub-org
# Authorize fullcopy
- name: 'Authorize fullcopy'
if: ${{ env.BRANCH_NAME == 'fullcopy' }}
run: sfdx auth:jwt:grant --clientid=${{secrets.PRODUCTION_CONSUMER_KEY}} --username=${{secrets.FULLCOPY_USERNAME}} --instanceurl=${{secrets.SFDC_LOGIN_SANDBOX_URL}} --jwtkeyfile server.key --setdefaultdevhubusername --setalias=hub-org
# Authorize preproduction
- name: 'Authorize preproduction'
if: ${{ env.BRANCH_NAME == 'preproduction'}}
run: sfdx auth:jwt:grant --clientid=${{secrets.PRODUCTION_CONSUMER_KEY}} --username=${{secrets.PRODUCTION_USERNAME}} --instanceurl=${{secrets.SFDC_LOGIN_PRODUCTION_URL}} --jwtkeyfile server.key --setdefaultdevhubusername --setalias=hub-org
# Create Delta for devops branch
- name: 'Install App and Create Delta for devops'
if: ${{ env.BRANCH_NAME == 'devops'}}
run: |
echo y | sfdx plugins:install sfdx-git-delta
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all
git --no-pager diff --name-status devops origin/fullcopy
sfdx sgd:source:delta --to devops --from origin/fullcopy --repo . --output .
cat package/package.xml
# Create Delta for devops-new branch
- name: 'Install App and Create Delta for devops-new'
if: ${{ env.BRANCH_NAME == 'devops-new'}}
run: |
echo y | sfdx plugins:install sfdx-git-delta
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all
git --no-pager diff --name-status devops-new origin/fullcopy
sfdx sgd:source:delta --to devops-new --from origin/fullcopy --repo . --output .
cat package/package.xml
# Create Delta for fullcopy branch
- name: 'Install App and Create Delta for fullcopy'
if: ${{ env.BRANCH_NAME == 'fullcopy'}}
run: |
echo y | sfdx plugins:install sfdx-git-delta
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all
git --no-pager diff --name-status fullcopy origin/preproduction
sfdx sgd:source:delta --to fullcopy --from origin/preproduction --repo . --output .
cat package/package.xml
# Create Delta for preproduction branch
- name: 'Install App and Create Delta for preproduction'
if: ${{ env.BRANCH_NAME == 'preproduction'}}
run: |
echo y | sfdx plugins:install sfdx-git-delta
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'
git fetch --all
git --no-pager diff --name-status preproduction origin/master
sfdx sgd:source:delta --to preproduction --from origin/master --repo . --output .
cat package/package.xml
# convert
- name: 'Convert Metadata'
run: sfdx force:source:convert --manifest=package/package.xml --outputdir=convert
# TestConfluence
- name: Read TestConfluence
id: testconfluence
uses: juliangruber/read-file-action@v1
with:
path: assets/TestConfluence.txt
trim: true
# Run Apex tests
- name: 'Run Apex tests on metadata'
run: sfdx force:mdapi:deploy --deploydir=convert --testlevel=RunSpecifiedTests --runtests=${{steps.testconfluence.outputs.content}} -u hub-org -w30