Expose commit timestamp in the github context data

Request: 

In the github context object, add committed_at (the commit timestamp for the commit referenced in github.sha):

github.sha // The commit SHA that triggered the workflow run.
github.ref // The branch or tag ref that triggered the workflow run.
github.committed_at // (NEW) The commit timestamp that triggered the workflow run.

Use case:

A workflow consisting of three jobs (“frontend”, “backend”, “report”).

The frontend/backend jobs generate test coverage data, which become artifacts (uploaded with `

actions/upload-artifact@v1`).

The report job is configured as:

report:
  name: Send coverage report to CodeClimate
  needs: [frontend, backend]
  runs-on: ubuntu-latest
  steps:
...

…so that it runs after the frontend/backend jobs successfully complete.

The report job uses CodeClimate test-reporter to format & merge the two coverage artifacts into a single payload, which is uploaded to CodeClimate.

test-reporter requires three context values:  GIT_BRANCH, GIT_COMMIT_SHA and GIT_COMMITTED_AT.
If these ENV variables aren’t set, test-report tries to extract them from the repo (using git rev-parse and git log).

The “report” job doesn’t need a checkout of the source code, so test-reporter can’t get the values using git rev-parse and git log), meaning that the 3 x ENV vars need to be set.

Ideally these could be set as:

env:
  GIT_BRANCH: ${{ github.ref }}
  GIT_COMMIT_SHA: ${{ github.sha }}
  GIT_COMMITTED_AT: ${{ ?? }}

However there is currently no suitable context value available for the GIT_COMMITTED_AT var.

Workaround:
The workaround it to simply check out the code (again) in the “report” job.

But as the job only needs context info from the commit SHA that triggered the workflow, the addition of a github.committed_at context value would remove the need for this checkout.

2 Likes

Hi @scottohara,

Thank you for being here and apologies for the delayed response. I’ve logged your feature request in our internal feature request list. Though I can’t guarantee anything or share a timeline for this, I can tell you that it’s been shared with the appropriate teams for consideration.

Please let me know if you have any other questions.

Cheers!

1 Like

Here is another possible workaround

name: CI
on:
  push

jobs:
  commit-at:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/github-script@0.3.0
        id: author-date
        with:
          github-token: ${{secrets.GITHUB_TOKEN}}
          script: |
            const commit_details = await github.git.getCommit({owner: context.repo.owner, repo: context.repo.repo, commit_sha: context.sha});
            return commit_details.data.author.date
      - run: echo $COMMITTED_AT
        env:
          COMMITTED_AT: ${{ steps.author-date.outputs.result }}