Commit Graph
1 Commits
Author SHA1 Message Date
Darryl L. Miles 5b15716666 git_utils.py: headers_try_to_add_authorization_from_environment(headers: dict)
This should make the project easier to setup and use and less likely to break
(through expired user tokens).

After this commit:
 * Pickup implicit GHA os.environ $GITHUB_ACTOR and $GITHUB_TOKEN by default.
    This will provide a good enough token for read-only access to public
    repositories.
 * Allow override with custom secret GH_USERNAME and/or GH_TOKEN just as
    before in those use cases where a token with additional scopes maybe needed
    to perform administrative actions.
   The values must be defined and non-blank to be considered.
   A non-blank expires token will cause failure (as before).
 * Continue on a best-effort basis (of not using any token to access public
    repositories) instead of failing the workflow immediately.
 * Emit a warning to stderr for diagnostic purpose from GHA and local shell
    in scenarios where no token is setup.

This means it is still correct to keep the *.yaml config as-is:
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    GH_USERNAME:  ${{ secrets.GH_USERNAME }}
    GH_TOKEN:     ${{ secrets.GH_TOKEN }}

Because a normal consumer of this project inside a GHA will utilise their
$GITHUB_ACTOR and $GITHUB_TOKEN values instead of acting upon blank values
for $GH_USERNAME and $GH_TOKEN.
2023-06-02 13:48:21 +01:00