Skip to content

Use latest version of GitHub Actions at seeding time. - #33

Merged
gouttegd merged 6 commits into
mainfrom
update-checkout
Sep 25, 2026
Merged

gouttegd merged 6 commits into
mainfrom
update-checkout

Conversation

@gouttegd

Copy link
Copy Markdown
Collaborator

When seeding a repository (or updating a pre-existing one), make sure the GitHub Actions referenced in the GitHub workflows (if GitHub workflows are used at all) are (i) referenced using a commit ID rather than a tag name, and (ii) the commit ID points to the latest released version.

This is done by having a small helper class (GitHubHelper) that encapsulates the required calls to the GitHub API to get the latest release information for a given project, and exposing that helper class to the templates, so that we can write the following in a template:

uses: actions/checkout@{{ gh.get_latest_release_sha("actions/checkout", "v7") }}

If we can get the required informations from GitHub, this will yield

uses: actions/checkout@XXXXX # vX.Y.Z

where vX.Y.Z is the latest release for the actions/checkout project, and XXXXX is the corresponding commit ID.

In the event we could not get the latest release info, then this will yield

uses: actions/checkout@v7

closes INCATools/ontology-development-kit#1346

When seeding a repository (or updating a pre-existing one), make sure
the GitHub Actions referenced in the GitHub workflows (if GitHub
workflows are used at all) are (i) referenced using a commit ID rather
than a tag name, and (ii) the commit ID points to the latest released
version.

This is done by having a small helper class (GitHubHelper) that
encapsulates the required calls to the GitHub API to get the latest
release information for a given project, and exposing that helper class
to the templates, so that we can write the following in a template:

  ```yaml
  uses: actions/checkout@{{ gh.get_latest_release_sha("actions/checkout", "v7") }}
  ```

  If we can get the required informations from GitHub, this will yield

  ```yaml
  uses: actions/checkout@XXXXX # vX.Y.Z
  ```

where `vX.Y.Z` is the latest release for the `actions/checkout` project,
and `XXXXX` is the corresponding commit ID.

In the event we could _not_ get the latest release info, then this will
yield

  ```yaml
  uses: actions/checkout@v7
  ```

closes INCATools/ontology-development-kit#1346
@gouttegd gouttegd self-assigned this Sep 21, 2026
@gouttegd
gouttegd requested a review from matentzn September 21, 2026 21:54
This commit does two things:

First, it simplifies the handling of exceptions thrown by the requests
library. All such exceptions are derived from the single
RequestException class, so since we are not interested in distinguishing
between the various error conditions, we can simply catch
RequestException instead of trying to catch all the various subclasses.

Second, it deals with the possibility that we could receive a response
that is not strictly speaking an error (HTTP status code < 400), but
that does not contain what we need either (e.g. status code == 204).
This is probably highly unlikely, but if it does happen, we must not
enter into an infinite loop.

@matentzn matentzn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Round 1 - I will check ones more after you re-request review

Comment thread src/incatools/odk/github.py
Comment thread src/incatools/odk/github.py
Comment thread src/incatools/odk/github.py Outdated
Comment thread src/incatools/odk/templates/_dynamic_workflows.jinja2
Comment thread src/incatools/odk/templates/_dynamic_workflows.jinja2 Outdated
The `mhausenblas/mkdocs-deploy-gh-pages` action has not had a new
release since 2023, but there has been some fixes on the master branch
since then, so we need to use the master branch. We add a comment next
to the tag for that action to make that a bit clearer.
If we somehow could not get the latest release tag for a given GitHub
Action, cache the negative result, so that we don't try again a
millisecond later the next time we need the tag for that action again.
@gouttegd
gouttegd requested a review from matentzn September 23, 2026 22:50

@matentzn matentzn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All my concerns addressed; some remaining doubts on the cost/benefit of not including a way to set a GH token but ok to try and retrofit if needed.

@gouttegd
gouttegd merged commit 367fce5 into main Sep 25, 2026
6 checks passed
@gouttegd
gouttegd deleted the update-checkout branch September 25, 2026 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update actions/checkout in GitHub Actions workflow

2 participants