Skip to content

Commit

Permalink
add status override (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianGoral-freenet authored Jun 25, 2024
1 parent c9bf498 commit 3ab7609
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ This is a fork of https://github.com/toko-bifrost/ms-teams-deploy-card with the
* Fix wrong input names in readme
* Write the branch instead of the commit hash in the Teams card.
* Add option to ignore failures caused by cancelling the workflow.
* Properly report matrix job status (see [Note when using matrix jobs](#note-matrix-jobs)).

### Screenshots of the modified cards:

Expand Down Expand Up @@ -71,6 +72,16 @@ jobs:
webhook-uri: ${{ secrets.MS_TEAMS_WEBHOOK_URI }}
```
#### <a name="note-matrix-jobs"></a>Note when using matrix jobs
The GitHub API makes it difficult to identify a specific matrix job from an action.
To properly pass the matrix job status to action, add the following step to the end of your workflow file:
```yaml
- run: echo "ms_teams_notification_job_status=${{ job.status }}" >> "$GITHUB_ENV"
if: always()
```
The notification action will pick up the environment variable and use it to determine the status of the matrix job.
### Configurations
#### Main Configurations
Expand Down
2 changes: 1 addition & 1 deletion dist/main/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/post/index.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,16 @@ export async function getWorkflowRunStatus() {
const startTime = moment(jobStartDate, moment.ISO_8601);
const endTime = moment(lastStep?.completed_at, moment.ISO_8601);

let conclusion;
if (process.env.ms_teams_notification_job_status) {
conclusion = process.env.ms_teams_notification_job_status;
} else {
conclusion = lastStep?.conclusion;
}

return {
elapsedSeconds: endTime.diff(startTime, "seconds"),
conclusion: lastStep?.conclusion,
conclusion: conclusion
};
}

Expand Down

0 comments on commit 3ab7609

Please sign in to comment.