-
Notifications
You must be signed in to change notification settings - Fork 0
146 lines (146 loc) · 5.93 KB
/
update-test-reporting-node.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
name: Update Test Reporting (Node)
on:
workflow_dispatch: # manual trigger
repository_dispatch: # repository trigger
types:
- test-reporting-node-release
env:
FORCE_COLOR: 3
concurrency: update-test-reporting-node
permissions:
contents: read
pull-requests: write
jobs:
update:
name: Update Test Reporting (Node)
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: Brightspace/third-party-actions@actions/checkout
with:
token: ${{secrets.PR_MANAGE_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
npm i -g npm-check-updates
- name: Get current version
id: current
run: |
VERSION=$(
npm ls --depth=0 -j d2l-test-reporting |
jq -r '.dependencies."d2l-test-reporting".version'
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Update test reporting
run: |
npm up d2l-test-reporting
ncu d2l-test-reporting -u
npm i
- name: Get new version
id: new
run: |
VERSION=$(
npm ls --depth=0 -j d2l-test-reporting |
jq -r '.dependencies."d2l-test-reporting".version'
)
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Build
if: steps.current.outputs.version != steps.new.outputs.version
run: npm run build
- name: Handle changes
uses: Brightspace/third-party-actions@peter-evans/create-pull-request
id: changes
if: steps.current.outputs.version != steps.new.outputs.version
with:
token: ${{secrets.PR_MANAGE_TOKEN}}
commit-message: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
branch: ghworkflow/update-test-reporting-node
title: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
body: Update `d2l-test-reporting` to `${{steps.new.outputs.version}}`
delete-branch: true
add-paths: |
dist/*
package.json
package-lock.json
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --squash --auto "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{secrets.PR_MANAGE_TOKEN}}
- name: Approve
if: >
steps.changes.outputs.pull-request-operation == 'created' ||
steps.changes.outputs.pull-request-operation == 'updated'
run: gh pr review --approve "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{github.token}}
- name: Get pull request age
if: steps.changes.outputs.pull-request-operation == 'updated'
id: pr-age
run: |
CREATED_AT=$(gh pr view "$PR_NUMBER" --json createdAt -q '.createdAt')
CREATED=$(date -d "$CREATED_AT" '+%s')
NOW=$(date '+%s')
DAYS_STALE="$((($NOW - $CREATED) / (24 * 60 * 60)))"
echo "days=$DAYS_STALE" >> $GITHUB_OUTPUT
env:
PR_NUMBER: ${{steps.changes.outputs.pull-request-number}}
GITHUB_TOKEN: ${{github.token}}
- name: Notify automation stale
if: >
steps.changes.outputs.pull-request-operation == 'updated' &&
fromJSON(steps.pr-age.outputs.days) > 3
uses: Brightspace/third-party-actions@slackapi/slack-github-action
env:
SLACK_BOT_TOKEN: ${{secrets.D2L_SLACK_TOKEN}}
with:
channel-id: '#quality-enablement-alerts'
payload: >
{
"username": "Stale Test Reporting PR",
"icon_emoji": ":update-package-lock:",
"unfurl_media": false,
"unfurl_links": false,
"text": ":warning: ${{github.repository}} -> PR #${{steps.changes.outputs.pull-request-number}} (${{github.server_url}}/${{github.repository}}/pull/${{steps.changes.outputs.pull-request-number}}) to d2l-test-reporting has been open for more than 3 days.",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":warning: `${{github.repository}}` -> <${{github.server_url}}/${{github.repository}}/pull/${{steps.changes.outputs.pull-request-number}}|PR #${{steps.changes.outputs.pull-request-number}}> to update `d2l-test-reporting` has been open for more than 3 days."
}
}
]
}
- name: Notify automation failure
if: failure()
uses: Brightspace/third-party-actions@slackapi/slack-github-action
env:
SLACK_BOT_TOKEN: ${{secrets.D2L_SLACK_TOKEN}}
with:
channel-id: '#quality-enablement-alerts'
payload: >
{
"username": "Update Test Reporting Issue",
"icon_emoji": ":update-package-lock:",
"unfurl_media": false,
"unfurl_links": false,
"text": ":fire: ${{github.repository}} -> Update run failed.\nSee ${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}} for details (trigger: ${{github.event_name}}, run attempt: ${{github.run_attempt}})",
"blocks": [
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": ":fire: `${{github.repository}}` -> Update run failed.\nSee the <${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}|run logs> for details (trigger: `${{github.event_name}}`, run attempt: ${{github.run_attempt}})"
}
}
]
}