-
Notifications
You must be signed in to change notification settings - Fork 0
160 lines (160 loc) · 5.3 KB
/
ci.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: CI
on: pull_request
env:
FORCE_COLOR: 3
permissions:
contents: read
jobs:
lint:
name: Lint
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Lint (ESLint)
run: npm run lint:eslint
- name: Lint (EditorConfig)
run: npm run lint:editorconfig
licenses:
name: Check Licenses
timeout-minutes: 5
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Check licenses
run: npm run license-check
build:
name: Build
timeout-minutes: 5
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
with:
token: ${{github.triggering_actor == 'devpow112' && secrets.PR_MANAGE_TOKEN || github.token}}
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Build
run: npm run build
- name: Handle changes (pull request)
uses: Brightspace/third-party-actions@peter-evans/create-pull-request
if: github.triggering_actor != 'devpow112'
id: changes-pr
with:
commit-message: Update Build
base: ${{github.event.pull_request.head.ref}}
branch: ghworkflow/update-build-for-pr-${{github.event.number}}
title: Update Build for PR ${{github.event.number}}
body: 'Update build for PR #${{github.event.number}}.'
delete-branch: true
draft: true
add-paths: dist/*
- name: Leave comment
if: >
github.triggering_actor != 'devpow112' &&
steps.changes-pr.outputs.pull-request-operation == 'created'
uses: BrightspaceUI/actions/comment-on-pr@main
with:
message: >
New build required - pull request
#${{steps.changes-pr.outputs.pull-request-number}} has been opened with
new built files.
post-mode: hide-previous
- name: Report status
if: >
github.triggering_actor != 'devpow112' &&
(
steps.changes-pr.outputs.pull-request-operation == 'created' ||
steps.changes-pr.outputs.pull-request-operation == 'updated'
)
uses: Brightspace/third-party-actions@actions/github-script
with:
script: core.setFailed('Build changes detected')
- name: Handle changes (push)
id: changes-push
if: github.triggering_actor == 'devpow112'
run: |
set +e
git diff --exit-code --name-only 'dist/*'
RESULT="$?"
set -e
if [[ "$RESULT" -eq 0 ]]; then
echo "No changes detected"
echo "exist=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "exist=true" >> $GITHUB_OUTPUT
git stash
git fetch -n origin "$GITHUB_HEAD_REF"
git checkout "$GITHUB_HEAD_REF"
git stash pop
git add 'dist/*'
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git commit -m 'Update Build'
git push -f "https://$GITHUB_TOKEN@github.com/$GITHUB_REPOSITORY" "$GITHUB_HEAD_REF"
env:
GITHUB_TOKEN: ${{secrets.PR_MANAGE_TOKEN}}
- name: Approve
if: steps.changes-push.outputs.exist == 'true'
run: gh pr review --approve "$PULL_REQUEST_NUMBER"
env:
PULL_REQUEST_NUMBER: ${{github.event.number}}
GITHUB_TOKEN: ${{github.token}}
test:
name: Test
timeout-minutes: 5
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
- name: Set up node
uses: Brightspace/third-party-actions@actions/setup-node
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm run test:unit
- name: Upload report (debug, dry run)
uses: ./
if: github.actor != 'dependabot[bot]'
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-session-token: ${{secrets.AWS_SESSION_TOKEN}}
dry-run: true
debug: true
- name: Upload report
uses: ./
if: github.actor != 'dependabot[bot]'
with:
aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}}
aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}}
aws-session-token: ${{secrets.AWS_SESSION_TOKEN}}