Installation¶
Prerequisites¶
Before starting, install the following on your local machine:
Note
Learn more about uv in the uv documentation ⧉
Setup¶
- Create a new GitHub repository using this template (
Use this templatebutton). - Name your repo (use underscores
_instead of hyphens-). - Add a project description (required!).
- Wait for the setup commit (done by
github-actions[bot], may take a few minutes).
Once complete, clone the repository and run uv run poe setup to install dependencies and set up the project.
Effects¶
The following features (and more) will be enabled:
- Ready-to-use state of the art project structure
- Set of
20+labels (see the OpenTemplate issue labels ⧉), many of which are automatically applied to pull requests - Predefined templates for issues, pull requests and discussions
- Initial dependency-specific caching enabled in GitHub Actions
Hardening¶
After the setup, an issue will be created (named Update repository settings) outlining security hardening steps.
Caution
Following these steps is strongly recommended for better security.
Hardening steps¶
Tip
These steps will be further detailed in the aforementioned issue.
- Enable third-party bots (if applicable).
- Create a short-lived, repository-scoped fine-grained PAT and save it as
TEMPLATE_GITHUB_TOKEN. Grant Contents: read and write, Workflows: read and write, Administration: read and write, and Pages: read and write. - Prefer a repository secret. An organization-level secret exposes the token to more repositories; if you use one, restrict it to the target repository.
- Manually run the hardening workflow using its existing workflow dispatch.
- Set up trusted PyPI publishing ⧉.
- For private repositories without GitHub Enterprise Cloud, set the
NO_GITHUB_ENTERPRISE_CLOUDconfiguration variable (repository or organization) to any value (e.g.true), as releases are attested by default (ignored for public and internal repositories). - For private repositories without GitHub Code Security (formerly part of GitHub Advanced Security), set the
NO_GITHUB_CODE_SECURITYconfiguration variable (repository or organization) to any value (e.g.true), as CodeQL runs and findings are uploaded to the Security tab by default (switch ignored for public and internal repositories, see security).
Warning
Any non-empty value disables the feature, including false. Delete the variable to enable it again.
Note
Full automation is not currently possible due to platform limitations.
Local hardening¶
Warning
If you ran the harden workflow feel free to skip it.
The executable scripts in .github/tools/harden apply individual settings locally and are also called by harden.yml.
| File | Purpose |
|---|---|
rulesets.sh | Apply repository rulesets |
pages.sh | Enable Pages via Actions |
pages-tags.sh | Allow Pages deployments from tags |
settings.sh | Configure repository settings |
security.sh | Enable security features |
codeql.sh | Disable CodeQL default setup |
discussions.sh | Enable discussions |
immutable-releases.sh | Enable immutable releases |
private-vulnerability-reporting.sh | Enable private reports |
vulnerability-alerts.sh | Enable Dependabot alerts and updates |
pypi.sh | Configure the PyPI release environment |
Install Bash, GitHub CLI (gh), and jq, then authenticate with gh auth login or GH_TOKEN using Administration write permission (also Pages write for Pages operations). Run scripts directly from the checkout root:
./.github/tools/harden/rulesets.sh 2 .github/rulesets
./.github/tools/harden/settings.sh
./.github/tools/harden/pages.sh
./.github/tools/harden/pages-tags.sh
GitHub CLI resolves the target from the current checkout; set GH_REPO=owner/repo to override it. Pass 0 approvals for solo projects, 1 for two contributors, or 2 for larger teams (just like hosted harden workflow).
Note
Local scripts apply only their selected settings and require the corresponding GitHub features to be available for the repository.
Note
Scripts are idempotent, existing rulesets will be deleted ONLY after new ones were created successfully.
Configure PyPI approvers locally:
Both arguments accept whitespace-separated values; use '' for an empty user or team list. The resolver requires at least two distinct people to allow an alternative approver when self-review is prevented. GitHub checks reviewer eligibility, repository access, and the six-reviewer limit when applying the environment. In the workflow, these errors can occur after other hardening changes have been applied. GitHub requires only one of those people to approve each deployment. Team lookups additionally need organization Members read permission (read:org for classic tokens). Users and team members are deduplicated by ID. The script resolves approvers before updating the environment. With no arguments, it uses BODY if nonempty, otherwise {}. Explicit arguments take precedence over BODY.
For solo projects or plans without environment reviewers, use the default:
Benefits¶
- Improved security following Open Source Security Foundation's Scorecard best practices ⧉.
- Enabled GitHub Pages for documentation hosting.
- Applied GitHub rulesets ⧉ (including branch protection rules ⧉).
- Required status checks (from GitHub Actions only) on a branch up to date with the default branch before merging.
- Blocked tags shadowing long-running branches (e.g., a
maintag). - Configured pull request defaults and other repository settings.
- Activated GitHub security features (e.g., private vulnerability reporting ⧉).
Warning
Exact features depend on repository type, but in general: public > enterprise > private.
Updates¶
Caution
This feature is not yet implemented.
The template update workflow is a placeholder and does not currently update repositories.
Code sources¶
/.github/workflows/template-setup.yml/.github/workflows/template-update.yml/.github/workflows/harden.yml/.github/tools/harden/.github/rulesets