Github actions setup

Github actions setup#

The following should be setup on the github page of the repo.

Copier/cruft update#

By default, the generated repo will have .github/workflows/update-copier.yml or .github/workflows/update-cruft.yml. These will periodically check for updates to the template and create a pr with changes. These require a token to trigger on: push and on: pull_request workflows, and to update workflow files. Create the token using one of the following:

Also, allow workflows to create pull requests

You’ll also need to use add an environment pull-request under Settings -> Environments.

Add the token to the github repo pull-requestenvironment using either:

  • Under Settings -> Environments -> pull-request -> Environment secrets add PAT with generated token.

  • Use github cli:

    gh secret set PAT --env pull-request
    

Trusted publishing#

Generated repos use [trusted publishing] to release the code to pypi and test.pypi. This requires defining the environments pypi and test-pypi, which can be created under Settings -> Environments of the github repo.

Rules#

It is a good idea to setup a merge rule. This can be done under Settings -> Rules -> Rulesets, using something like the following:

  • Add main to Target branches using Include by pattern

  • Select Require status checks to pass. Add pre-commit.ci - pr and required-checks-pass to the Status checks that are required list.