How do I get a workflow's run duration after a re-run was triggered?

I want to calculate the time a workflow run takes to complete, up to a certain step.
To achieve this, I am using the “get a workflow run” API, in conjunction with the datediff utility found in dateutils like this:

- name: Get workflow Run ID
  uses: octokit/request-action@v2.x
  id: workflowRunId
  with:
    route: GET /repos/$myorg/$myrepo/actions/runs/${{ github.run_id }}
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    
- name: Get time diff between now and workflow run creation time
  id: workflowDuration
  run: |
    rpm -qa | grep dateutils || rpm -i https://download.opensuse.org/repositories/utilities/RHEL_7/x86_64/dateutils-0.4.4-44.1.x86_64.rpm
    NOW=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
    DIFF=`ddiff -i "%Y-%m-%dT%H:%M:%SZ" "${{ fromJson(steps.workflowRunId.outputs.data).created_at }}" $NOW -f "%H°%M'%S\" to complete."`

However, if the run fails and then gets restarted, the above code outputs the diff between the first run (when the run was first “created_at”), not the timestamp that it got re-triggered.

Does anyone know how to do this with the API, or even with some other method?
Thanks!