Ah I've hit this before myself. Does seem mad they're still not giving access to this in the workflow run.
Obviously it's straight-forward to track it yourself (though annoying you have to):
- Set a timestamp right at the start of the run, here I'm passing it to an output parameter called startTimestamp
- name: Set start timestamp
id: start-timestamp
run: |
printf 'startTimestamp=%(%s)T\n' >> "$GITHUB_OUTPUT"
- Post-build, calculate the duration comparing the current time to start time. Can then use this in any following steps, whether sending to a log, Slack, etc!
- Note in this example I'm assuming the workflow is broken into separate jobs - an initial "pre-build" job, and then the latter in a "post-build" job
- name: Calculate build duration
id: calculate-duration
run: |
printf -v now '%(%s)T'
echo buildDuration=$((now - ${{ needs.pre-build.outputs.startTimestamp }})) >> "$GITHUB_OUTPUT"