ably / repository-audit

Oversight for our estate of repositories, in particular those in the public domain. Audit. Monitor. Conform.
Apache License 2.0
11 stars 2 forks source link

Use GitHub environment variables #4

Closed QuintinWillison closed 3 years ago

QuintinWillison commented 3 years ago

There should be no need to hardcode any GitHub URL components into this codebase - specifically, right now, I'm thinking of the repository hyperlinks and the upstream commit link in the downstream commit message.

Using GITHUB_SERVER_URL, the org we're querying and GITHUB_REPOSITORY should be all that's needed.

See: Learn GitHub Actions: Environment Variables

QuintinWillison commented 3 years ago

Observations from https://github.com/ably/repository-audit/pull/14 in respect of the environment variables that relate to analysis of 'pull request vs main':

Environment Variable Value for Pull Request Value for main
GITHUB_SHA f79a3b624475e47848eea92758d53b13a526bb4e 37aa814eba9d238fc948ad0957839cb1e3c6869c
GITHUB_REF refs/pull/14/merge refs/heads/main
GITHUB_EVENT_NAME pull_request push
GITHUB_BASE_REF main
GITHUB_HEAD_REF explore-github-environment
QuintinWillison commented 3 years ago

Observations from #14 in respect of the environment variables that can contribute to us dynamically generating the link to the commit that generated the report:

So, the current hard-coded version:

`https://github.com/ably/repository-audit/commit/${sha}`

Can be replaced with:

`${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${sha}`