Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build

env:
NODE_VERSION: "24"

on:
push:
branches:
- "main"
paths:
- "scripts/**"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- "biome.json"
- ".github/workflows/build.yml"
pull_request:
paths:
- "scripts/**"
- "package.json"
- "package-lock.json"
- "tsconfig.json"
- "biome.json"
- ".github/workflows/build.yml"
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
name: Lint & Format
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run Biome check
run: npm run check

- name: Check TypeScript
run: npm run typecheck
43 changes: 34 additions & 9 deletions .github/workflows/labels.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,61 @@
name: Labels

env:
NODE_VERSION: "24"

# Brings the shared labels in labels.yml to every public repository: creates
# the missing ones and corrects colour and description. Labels a repository
# keeps for its own areas are never touched or deleted.
on:
push:
branches: [main]
paths: [labels.yml, scripts/labels-sync.mjs]
branches:
- "main"
paths:
- "labels.yml"
- "scripts/labels-sync.ts"
- "scripts/github.ts"
- "package.json"
- "package-lock.json"
- ".github/workflows/labels.yml"
schedule:
# Daily, so a newly created repository gets the labels without a push.
- cron: "0 6 * * *"
workflow_dispatch:

permissions:
contents: read

jobs:
sync:
name: Sync labels
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: actions/setup-node@v4
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci --omit=dev

- id: app
uses: actions/create-github-app-token@v2
- name: Create app token
id: app
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.PROJECT_APP_ID }}
# nvisy-bot. A client ID is public; only the private key is a secret.
client-id: Iv23li4OFiUQmJcoK9mo
private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- run: node scripts/labels-sync.mjs
- name: Sync labels
run: node scripts/labels-sync.ts
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
ORG: ${{ github.repository_owner }}
35 changes: 26 additions & 9 deletions .github/workflows/project-sync.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
name: Project sync

env:
NODE_VERSION: "24"

# Adds every open issue and human pull request in the organization's public
# repositories to the "Nvisy OSS" project. Safe to run any number of times.
# repositories that is not yet on the "Nvisy OSS" project. GitHub runs
# schedules late and drops some under load, so the cron is a ceiling on
# frequency, not a promise: new items can take a few hours to appear.
on:
schedule:
- cron: "*/15 * * * *"
Expand All @@ -21,25 +26,37 @@ concurrency:

jobs:
sync:
name: Sync project
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v4
- name: Checkout
uses: actions/checkout@v7
with:
persist-credentials: false

- uses: actions/setup-node@v4
- name: Setup Node.js
uses: actions/setup-node@v7
with:
node-version: 24
node-version: ${{ env.NODE_VERSION }}
cache: "npm"

- name: Install dependencies
run: npm ci --omit=dev

# The default GITHUB_TOKEN cannot write to organization projects, so the
# sync runs as the organization's project app.
- id: app
uses: actions/create-github-app-token@v2
# sync runs as the organization's nvisy-bot app.
- name: Create app token
id: app
uses: actions/create-github-app-token@v3
with:
app-id: ${{ vars.PROJECT_APP_ID }}
# nvisy-bot. A client ID is public; only the private key is a secret.
client-id: Iv23li4OFiUQmJcoK9mo
private-key: ${{ secrets.PROJECT_APP_PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- run: node scripts/project-sync.mjs
- name: Sync project
run: node scripts/project-sync.ts
env:
GH_TOKEN: ${{ steps.app.outputs.token }}
ORG: ${{ github.repository_owner }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
.DS_Store
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,26 @@ Organization-wide defaults and automation for Nvisy's open-source repositories.
- **Issue forms and pull request template** (`.github/`): used by every
repository that has none of its own. The forms set the organization's issue
types (Bug, Feature, Task).
- **Project sync** (`scripts/project-sync.mjs`, every 15 minutes): adds every
open issue and human pull request in a public repository to the
[Nvisy OSS](https://github.com/orgs/nvisycom/projects/7) project. Status
after that is kept by the project's built-in workflows.
- **Project sync** (`scripts/project-sync.ts`): adds every open issue and
human pull request in a public repository to the
[Nvisy OSS](https://github.com/orgs/nvisycom/projects/7) project. It runs on
a 15-minute schedule, which GitHub runs late and sometimes hours apart, so a
new item can take a few hours to appear. Status after that is kept by the
project's built-in workflows.
- **Labels** (`labels.yml`): the labels every public repository shares,
synced on change. Repositories keep their own area labels alongside.
synced on change and daily. Repositories keep their own area labels alongside.

Both workflows authenticate as the organization's project app: its id in the
`PROJECT_APP_ID` variable and its key in the `PROJECT_APP_PRIVATE_KEY` secret.
Run either script locally with `GH_TOKEN=$(gh auth token)`; set `DRY_RUN=1` on
the project sync to see what it would add.
## Authentication

Both workflows run as the organization's `nvisy-bot` app. Its client ID is in
the workflows; its private key is this repository's `PROJECT_APP_PRIVATE_KEY`
secret, which never leaves this repository.

## Development

The scripts are TypeScript that Node 24 runs directly, so there is no build
step. They talk to GitHub through [Octokit](https://github.com/octokit/octokit.js),
which handles pagination, retries and rate limits (`scripts/github.ts`).
`npm ci` also installs Biome and the type checker for `npm run check` and
`npm run typecheck`. Run either script locally with
`GH_TOKEN=$(gh auth token)`; set `DRY_RUN=1` to see what it would change.
32 changes: 32 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"$schema": "https://biomejs.dev/schemas/2.6.9/schema.json",
"vcs": {
"enabled": true,
"clientKind": "git",
"useIgnoreFile": true
},
"files": {
"ignoreUnknown": false,
"includes": ["**", "!node_modules", "!.claude"]
},
"formatter": {
"enabled": true,
"indentStyle": "tab"
},
"assist": { "actions": { "source": { "preset": "recommended" } } },
"linter": {
"enabled": true,
"rules": {
"preset": "recommended",
"style": {
"preset": "recommended",
"noNonNullAssertion": "off"
}
}
},
"javascript": {
"formatter": {
"quoteStyle": "double"
}
}
}
Loading