Skip to content

Commit

Permalink
Create calculate-build-duration.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
joshjohanning committed Jun 21, 2024
1 parent 2f12ca4 commit dffc3bb
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/calculate-build-duration.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: calculate-build-duration

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
# only needed if we have a second job where we would reference this
outputs:
start_time: ${{ steps.set-start-time.outputs.start_time }}

steps:
- name: Set start time
id: set-start-time
run: echo "start_time=$(date +%s)" >> $GITHUB_OUTPUT

- uses: actions/checkout@v4

- name: Write GitHub context to log
env:
GITHUB_CONTEXT: ${{ toJSON(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Write job context to log
env:
JOB_CONTEXT: ${{ toJSON(job) }}

- run: sleep 5s

- name: Calculate build duration
run: |
END_TIME=$(date +%s)
START_TIME=${{ steps.set-start-time.outputs.start_time }}
DURATION=$((END_TIME - START_TIME))
echo "Build duration: $DURATION seconds"

0 comments on commit dffc3bb

Please sign in to comment.