Skip to content

Commit d76043b

Browse files
authored
Fix workflow job conclusion when using NodeJS matrix strategy (#12)
1 parent fa33bd1 commit d76043b

File tree

5 files changed

+622
-509
lines changed

5 files changed

+622
-509
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
- uses: actions/checkout@v2
1313
test: # make sure the action works on a clean machine without building
1414
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
node: [8, 10]
1518
steps:
1619
- uses: actions/checkout@v2
1720
- uses: ./

dist/main/index.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opsless/ms-teams-github-actions",
3-
"version": "0.1.1",
3+
"version": "0.1.5",
44
"private": true,
55
"description": "MS Teams Github Actions integration",
66
"main": "lib/main.js",

src/main.ts

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ async function sleep(ms: number): Promise<unknown> {
88
})
99
}
1010

11+
enum Conclusions {
12+
SUCCESS = 'success',
13+
FAILURE = 'failure',
14+
NEUTRAL = 'neutral',
15+
CANCELLED = 'cancelled',
16+
SKIPPED = 'skipped',
17+
TIMED_OUT = 'timed_out',
18+
ACTION_REQUIRED = 'action_required'
19+
}
20+
21+
enum StepStatus {
22+
QUEUED = 'queued',
23+
IN_PROGRESS = 'in_progress',
24+
COMPLETED = 'completed'
25+
}
26+
1127
async function run(): Promise<unknown> {
1228
try {
1329
const token = core.getInput('github-token')
@@ -37,18 +53,18 @@ async function run(): Promise<unknown> {
3753
const jobs = jobList.data.jobs
3854
core.debug(JSON.stringify(jobs))
3955

40-
const job = jobs.find(j => j.name === ctx.job)
56+
const job = jobs.find(j => j.name.startsWith(ctx.job))
4157

4258
const stoppedStep = job?.steps.find(
4359
s =>
44-
s.conclusion === 'failure' ||
45-
s.conclusion === 'timed_out' ||
46-
s.conclusion === 'cancelled' ||
47-
s.conclusion === 'action_required'
60+
s.conclusion === Conclusions.FAILURE ||
61+
s.conclusion === Conclusions.TIMED_OUT ||
62+
s.conclusion === Conclusions.TIMED_OUT ||
63+
s.conclusion === Conclusions.ACTION_REQUIRED
4864
)
4965
const lastStep = stoppedStep
5066
? stoppedStep
51-
: job?.steps.reverse().find(s => s.status === 'completed')
67+
: job?.steps.reverse().find(s => s.status === StepStatus.COMPLETED)
5268

5369
const wr = await o.actions.getWorkflowRun({
5470
owner: ctx.repo.owner,
@@ -62,15 +78,15 @@ async function run(): Promise<unknown> {
6278
const commit_author = ctx.actor
6379

6480
const themeColor =
65-
lastStep?.conclusion === 'success'
81+
lastStep?.conclusion === Conclusions.SUCCESS
6682
? '90C978'
67-
: lastStep?.conclusion === 'cancelled'
83+
: lastStep?.conclusion === Conclusions.CANCELLED
6884
? 'FFF175'
6985
: 'C23B23'
7086
const conclusion =
71-
lastStep?.conclusion === 'success'
87+
lastStep?.conclusion === Conclusions.SUCCESS
7288
? 'SUCCEEDED'
73-
: lastStep?.conclusion === 'cancelled'
89+
: lastStep?.conclusion === Conclusions.CANCELLED
7490
? 'CANCELLED'
7591
: 'FAILED'
7692

0 commit comments

Comments
 (0)