@vivswan/github-settings-as-code 0.0.0 → 2.0.1-main.658.20260922.gdcb742f
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +561 -1
- package/README.md +101 -2
- package/lib/pkg/cli.js +722 -0
- package/lib/pkg/index.d.ts +157 -0
- package/lib/pkg/index.js +3 -0
- package/lib/pkg/inputs-BOuUCdpl.js +15883 -0
- package/lib/pkg/internal-la_KkjCS.js +1 -0
- package/lib/pkg/internal.d.ts +49 -0
- package/lib/pkg/internal.js +3 -0
- package/lib/pkg/layers-MA87H-hC.d.ts +9786 -0
- package/lib/pkg/src-C2gb8QkD.js +160 -0
- package/lib/settings.schema.json +4128 -0
- package/package.json +91 -3
package/README.md
CHANGED
|
@@ -1,3 +1,102 @@
|
|
|
1
|
-
#
|
|
1
|
+
# GitHub Settings as Code
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://socket.dev/npm/package/@vivswan/github-settings-as-code) [](https://github.com/Vivswan/github-settings-as-code/actions/workflows/ci.yml?query=branch%3Amain) [](https://github.com/Vivswan/github-settings-as-code/releases/latest) [](https://www.npmjs.com/package/@vivswan/github-settings-as-code) [](https://www.npmjs.com/package/@vivswan/github-settings-as-code?activeTab=versions)
|
|
4
|
+
|
|
5
|
+
Apply declarative repository settings from `.github/settings.yml`: a loud, stateless replacement for the [Probot Settings app](https://github.com/repository-settings/app) that also manages [rulesets](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-rulesets/about-rulesets) (branch, tag, and push). Every apply is a visible workflow run that fails with the API's error message; nothing happens silently. The full documentation lives in [docs/](docs/README.md).
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
1. Create a [fine-grained PAT](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token) from the [pre-filled token form][pat-form] and save it as the `ADMIN_TOKEN` repository secret. The form starts with every repository permission the action can need (an organization owner adds Members: read by hand); the default `GITHUB_TOKEN` can never hold them.
|
|
10
|
+
|
|
11
|
+
2. Add `.github/settings.yml` (or start from a [snapshot](docs/operate/snapshot.md) of the live settings). The first line gives editor autocomplete and hover docs:
|
|
12
|
+
|
|
13
|
+
```yaml
|
|
14
|
+
# yaml-language-server: $schema=https://raw.githubusercontent.com/Vivswan/github-settings-as-code/v2/lib/settings.schema.json # x-release-please-major
|
|
15
|
+
|
|
16
|
+
repository:
|
|
17
|
+
description: My project
|
|
18
|
+
delete_branch_on_merge: true
|
|
19
|
+
|
|
20
|
+
labels:
|
|
21
|
+
- name: bug
|
|
22
|
+
color: "d73a4a"
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
3. Add the workflow and run it from the Actions tab.
|
|
26
|
+
- Keep `mode: check` for the first run: the drift report lists everything an apply would change or delete, and nothing is written.
|
|
27
|
+
- Read the report. An apply deletes undeclared labels, autolinks, collaborators, Actions variables, and Copilot agents variables.
|
|
28
|
+
- Drop the `mode: check` line once the report says what you expect. The [getting started guide](docs/start/getting-started.md) explains the drift output.
|
|
29
|
+
|
|
30
|
+
```yaml
|
|
31
|
+
# .github/workflows/settings.yml
|
|
32
|
+
name: Apply Settings
|
|
33
|
+
on:
|
|
34
|
+
push:
|
|
35
|
+
branches: [main]
|
|
36
|
+
paths: [.github/settings.yml]
|
|
37
|
+
workflow_dispatch:
|
|
38
|
+
|
|
39
|
+
permissions:
|
|
40
|
+
contents: read
|
|
41
|
+
|
|
42
|
+
jobs:
|
|
43
|
+
apply:
|
|
44
|
+
runs-on: ubuntu-latest
|
|
45
|
+
steps:
|
|
46
|
+
- uses: actions/checkout@v7
|
|
47
|
+
- uses: Vivswan/github-settings-as-code@v2 # x-release-please-major
|
|
48
|
+
with:
|
|
49
|
+
token: ${{ secrets.ADMIN_TOKEN }}
|
|
50
|
+
mode: check
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Versioning
|
|
54
|
+
|
|
55
|
+
| Pin | Points at | Use it for |
|
|
56
|
+
|---|---|---|
|
|
57
|
+
| `@v2` <!-- x-release-please-major --> | The newest release in the major line, so fixes arrive without changing your pin | Production |
|
|
58
|
+
| `@vX.Y.Z` or a commit SHA | One release, frozen by a ruleset | Byte-stable behavior |
|
|
59
|
+
| `@latest` | The newest green `main` commit, packaged; breaking changes arrive here unannounced, ahead of any release | Trying unreleased fixes |
|
|
60
|
+
|
|
61
|
+
- Every pin points at a packaged commit: the child of one `main` commit, carrying its tree plus the built action. `main` is source-only and not runnable as an action. The tags up to v2.0.0 point at release commits on `main` from when `main` still committed the bundle.
|
|
62
|
+
- v2 activates settings keys that were inert on v1: `actions.oidc_customization_sub`, `actions.fork_pr_contributor_approval`, `actions.fork_pr_workflows_private_repos`, and `branches[].protection.required_signatures`. Audit them before moving a `@v1` pin; a stale `required_signatures: false` would remove a hand-enabled requirement.
|
|
63
|
+
- Only the latest release is supported; fixes are not backported (see [SECURITY.md](.github/SECURITY.md)). Each major has an [upgrade guide](docs/upgrading/README.md).
|
|
64
|
+
|
|
65
|
+
## Library
|
|
66
|
+
|
|
67
|
+
The same engine is the npm package `@vivswan/github-settings-as-code` (ESM, Node 22.14 or newer): validate, merge, check, and apply from your own code.
|
|
68
|
+
|
|
69
|
+
- `npm install @vivswan/github-settings-as-code` installs the released version; `@next` installs the pre-release of the `main` commit release-please last refreshed the release PR on ([Versioning](docs/reference/library.md#versioning)). The [library reference](docs/reference/library.md) has the API by group and the versioning rules.
|
|
70
|
+
- `npx @vivswan/github-settings-as-code@next check --repository o/r --settings-file .github/settings.yml` runs the action's check from a terminal. The [command line guide](docs/start/cli.md) has every command.
|
|
71
|
+
|
|
72
|
+
## Docs
|
|
73
|
+
|
|
74
|
+
| Goal | Read |
|
|
75
|
+
|---|---|
|
|
76
|
+
| Get one repository under management | [Getting started](docs/start/getting-started.md) |
|
|
77
|
+
| Copy a settings.yml shape | [Examples](docs/start/examples.md) |
|
|
78
|
+
| Look up what a section manages and deletes | [Sections](docs/reference/sections.md) |
|
|
79
|
+
| Look up an input or output | [Inputs and outputs](docs/reference/inputs.md) |
|
|
80
|
+
| Predict what an apply or a check will do | [Semantics](docs/reference/semantics.md) |
|
|
81
|
+
| Scope the token | [Token permissions](docs/reference/permissions.md) |
|
|
82
|
+
| Decide what happens to resources the file does not declare | [The undeclared policy](docs/reference/undeclared-policy.md) |
|
|
83
|
+
| Feed secret values from GitHub Secrets or a vault | [Secrets and vaults](docs/reference/secrets-and-vaults.md) |
|
|
84
|
+
| Detect drift without changing anything | [Check mode](docs/operate/check-mode.md) |
|
|
85
|
+
| Manage a fleet from one repository | [Multi-repo mode](docs/operate/multi-repo.md) |
|
|
86
|
+
| Layer settings files and fold them with `mode: render` | [Layering settings files](docs/operate/layering.md) |
|
|
87
|
+
| Keep private targets out of public logs | [Private repositories](docs/operate/private-repositories.md) |
|
|
88
|
+
| Replace the Probot Settings app | [Migrating from Probot](docs/start/migrating-from-probot.md) |
|
|
89
|
+
| Adapt a complete platform-team workflow | [Playbooks](docs/playbooks/README.md) |
|
|
90
|
+
| Read a failing run | [Troubleshooting](docs/operate/troubleshooting.md) |
|
|
91
|
+
| Move a pin to a new major | [Upgrading](docs/upgrading/README.md) |
|
|
92
|
+
| See how the code is laid out | [Architecture](docs/reference/architecture.md) |
|
|
93
|
+
| Use the engine from your own code | [Library](docs/reference/library.md) |
|
|
94
|
+
| Run check, apply, or validate from a terminal | [Command line](docs/start/cli.md) |
|
|
95
|
+
|
|
96
|
+
## Contributing
|
|
97
|
+
|
|
98
|
+
The toolchain, the end-to-end harness, and the PR conventions are in [CONTRIBUTING.md](CONTRIBUTING.md). Licensed under the [Individual and Small Organization License](LICENSE.md).
|
|
99
|
+
|
|
100
|
+
<!-- BEGIN GENERATED: readme-pat-url (bun run build:docs; derived from RESOURCE_SLUGS in src/sections/contract/permissions.ts) -->
|
|
101
|
+
[pat-form]: https://github.com/settings/personal-access-tokens/new?name=github-settings-as-code&description=Token+for+Vivswan%2Fgithub-settings-as-code&administration=write&issues=write&environments=write&pages=write&actions=write&actions_variables=write&repository_hooks=write&checks=write&secrets=write&dependabot_secrets=write&codespaces_secrets=write&agent_secrets=write&agent_variables=write&repository_custom_properties=write&secret_scanning_alerts=write&contents=read
|
|
102
|
+
<!-- END GENERATED: readme-pat-url -->
|