From dffc3bbf8b35b3cc6584b6307ae0a5e6e8945f4c Mon Sep 17 00:00:00 2001 From: Josh Johanning Date: Fri, 21 Jun 2024 08:41:37 -0500 Subject: [PATCH] Create calculate-build-duration.yml --- .../workflows/calculate-build-duration.yml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/calculate-build-duration.yml diff --git a/.github/workflows/calculate-build-duration.yml b/.github/workflows/calculate-build-duration.yml new file mode 100644 index 0000000..8dcb2c6 --- /dev/null +++ b/.github/workflows/calculate-build-duration.yml @@ -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" +