I'd like to add to the Slack message that notifies that a Github workflow run has finished, the total duration it took to run.
Does anyone know how can it be achieved? I couldn't find "total duration" in any of the contexts...
I'd like to add to the Slack message that notifies that a Github workflow run has finished, the total duration it took to run.
Does anyone know how can it be achieved? I couldn't find "total duration" in any of the contexts...
I don't think it's available from a context, but you could do it with two separate run
steps:
Store the current time as a timestamp (first step in workflow):
- name: Set start timestamp
id: start
run: |
printf 'timestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
Calculate difference (at end of workflow):
- name: Calculate duration
run: |
printf -v now '%(%s)T'
duration=$((now - ${{ steps.start.outputs.timestamp }}))
# Do something with duration, set as output to then use in Slack message
# or similar
This puts the duration in seconds into the duration
variable.