Skip to content

Commit

Permalink
[AAE-17087] new-notification when build time exceeded (#333)
Browse files Browse the repository at this point in the history
Co-authored-by: Anahide Tchertchian <[email protected]>
Co-authored-by: Giovanni Toraldo <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2023
1 parent fe3ae25 commit 7d8cfaa
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/actions/send-slack-notification-slow-job/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Send a notification for exceeded build time
description: Send a slack notification if build took more than planned

inputs:
max-build-time-seconds:
description: Maximum acceptable build time in seconds
required: true
slack-token:
description: The slack token
required: true
slack-channel:
description: The slack channel id, channel name, or user id to post to
required: true

runs:
using: composite
steps:
- name: Fetch billable time from gh API
id: fetch_time
shell: bash
run: |
total_time=$(gh api /repos/${{github.repository}}/actions/runs/${{github.run_id}}/timing | jq ' .billable.UBUNTU.total_ms /1000')
echo "total_time in seconds: ${total_time}"
echo "total_time=${total_time}" >> $GITHUB_OUTPUT
- name: Slack Notification
if: fromJSON(steps.fetch_time.outputs.total_time) > fromJSON(inputs.max-build-time-seconds)
uses: Alfresco/alfresco-build-tools/.github/actions/[email protected]
with:
channel-id: ${{ inputs.slack-channel }}
message: 'Max build time exceeded: took ${{ steps.fetch_time.outputs.total_time }} seconds (expected max: ${{ inputs.max-build-time-seconds }} seconds)'
token: ${{ inputs.slack-token }}
13 changes: 13 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1040,6 +1040,19 @@ This will give the following sample output on the GH Actions run summary (when u

![GH Actions Summary Report Portal](./images/rp-gh-summary.png)

### send-slack-notification-slow-job

Sends a slack notification when current run took more time than specified via `max-build-time-seconds` input.
This action should be added at the end to correctly measure the time.

```yaml
- uses: Alfresco/alfresco-build-tools/.github/actions/send-slack-notification-slow-job@ref
with:
channel-id: 'channel-id'
token: ${{ secrets.SLACK_BOT_TOKEN }}
max-build-time-seconds: '10'
```

### send-slack-notification

Sends a slack notification with a pre-defined payload, relying on the [slackapi/slack-github-action](https://github.com/slackapi/slack-github-action) official action.
Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v3.4.1
v3.5.0

0 comments on commit 7d8cfaa

Please sign in to comment.