-
-
Notifications
You must be signed in to change notification settings - Fork 30
122 lines (107 loc) · 3.97 KB
/
deploy.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: Rollup Release Status
on:
push:
branches:
- main
paths-ignore:
- 'sfdx-project.json'
- '**/README.md'
- 'Contributing.md'
- 'CODE_OF_CONDUCT.md'
- 'package.json'
- 'LICENSE'
- 'media/**'
- '.gitignore'
- '.prettierignore'
- '.prettierrc'
pull_request:
types: [opened, synchronize, reopened]
paths-ignore:
- 'sfdx-project.json'
- '**/README.md'
- 'Contributing.md'
- 'CODE_OF_CONDUCT.md'
- 'package.json'
- 'LICENSE'
- 'media/**'
- '.gitignore'
- '.prettierignore'
- '.prettierrc'
jobs:
scratch-org-test:
runs-on: ubuntu-latest
environment: Test
steps:
# Checkout the code
- name: 'Checkout source code'
uses: actions/checkout@v2
with:
ref: ${{ github.head_ref }}
- name: 'Setup node'
uses: actions/setup-node@v2
with:
node-version: '14'
- name: 'Restore node_modules cache'
id: cache-npm
uses: actions/cache@v2
with:
path: node_modules
key: npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
npm-${{ env.cache-name }}-
npm-
- name: 'Install NPM'
if: steps.cache-npm.outputs.cache-hit != 'true'
run: npm ci
- name: 'Run LWC Unit Tests'
run: npm run test:lwc
- name: 'Upload code coverage for LWC to Codecov.io'
uses: codecov/codecov-action@v2.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: LWC
- name: 'Delete LWC test files after codecov upload'
run: |
rm coverage/ -rf
- name: Install & run SFDX Scanner
run: npm run scan
# Authenticate using JWT flow
- name: 'Auth to dev hub'
shell: bash
run: |
echo "${{ env.DEVHUB_SERVER_KEY }}" > ./jwt-server.key
npx sfdx force:auth:jwt:grant --clientid ${{ env.DEVHUB_CONSUMER_KEY }} --username ${{ env.DEVHUB_USERNAME }} --jwtkeyfile ./jwt-server.key --setdefaultdevhubusername
npx sfdx config:set defaultusername=${{ env.DEVHUB_USERNAME }}
env:
DEVHUB_USERNAME: ${{ secrets.DEVHUB_USERNAME }}
DEVHUB_CONSUMER_KEY: ${{ secrets.DEVHUB_CONSUMER_KEY }}
DEVHUB_SERVER_KEY: ${{ secrets.DEVHUB_SERVER_KEY }}
- name: 'Deploy & Test'
shell: pwsh
run: '. ./scripts/test.ps1'
# Delete temporary test files that Codecov is unable to parse
- name: 'Delete unparseable test coverage'
run: rm ./tests/apex/test-result-707*-codecoverage.json -f
# Upload Apex code coverage data
- name: 'Upload Apex code coverage for Apex to Codecov.io'
uses: codecov/codecov-action@v2.0.2
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: Apex
verbose: true
# Only create new package versions if a PR is pointed to main or we are merging to main
- name: 'Package & Promote'
shell: pwsh
if: ${{ env.SHOULD_CREATE_AND_PROMOTE == '1' && github.actor == github.event.repository.owner.login && (github.base_ref == 'main' || github.ref == 'refs/heads/main') }}
run: '. ./scripts/build-and-promote-package.ps1'
env:
SHOULD_CREATE_AND_PROMOTE: ${{ secrets.SHOULD_CREATE_AND_PROMOTE }}
# Package versions are only created automatically within PRs that are pointed to main
# so those are the only times we need to update the README /sfdx-project.json and package.json
- name: 'Re-commit updated package version (if necessary)'
if: ${{ github.ref != 'refs/heads/main' && env.SHOULD_CREATE_AND_PROMOTE == '1' && github.actor == github.event.repository.owner.login && github.base_ref == 'main' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SHOULD_CREATE_AND_PROMOTE: ${{ secrets.SHOULD_CREATE_AND_PROMOTE }}
run: 'sh ./scripts/updateGithubCommitStatus.sh'