-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Labels on the repo are now defined through a `labels.yml` file and maintained through a GitHub action.
- Loading branch information
1 parent
619ac28
commit ca45d3a
Showing
15 changed files
with
928 additions
and
394 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
labels: | ||
affects:all: | ||
color: "0DDAFA" | ||
description: Not browser-specific | ||
affects:build: | ||
color: "0DDAFA" | ||
description: An issue with the build process | ||
affects:chrome: | ||
color: "0DDAFA" | ||
description: Has been observed in Chrome | ||
affects:firefox: | ||
color: "0DDAFA" | ||
description: Has been observed in Firefox | ||
|
||
dependencies: | ||
color: "BFD4F2" | ||
description: Pull requests that update a dependency file | ||
# https://docs.github.com/en/issues/using-labels-and-milestones-to-track-work/managing-labels#about-default-labels | ||
good first issue: | ||
color: "7057ff" | ||
description: If you haven't contributed yet, this might be a good place to start | ||
help wanted: | ||
color: "008672" | ||
description: We can't figure this out, please help | ||
|
||
needs:confirmation: | ||
color: "eb6420" | ||
description: A developer should confirm this issue happening | ||
needs:merge: | ||
color: "eb6420" | ||
description: This work has been completed. It needs to be merged | ||
needs:research: | ||
color: "eb6420" | ||
description: We don't know enough. Someone needs to look into it | ||
needs:testing: | ||
color: "eb6420" | ||
description: Work has been done. Someone needs to test it | ||
needs:triage: | ||
color: "eb6420" | ||
description: A developer needs to look at this | ||
needs:work: | ||
color: "eb6420" | ||
description: It's clear what needs to be done. Now we need to do it | ||
|
||
prio:accepted: | ||
color: "53F643" | ||
description: Tickets under active consideration for implementation | ||
prio:beta: | ||
color: "016E96" | ||
description: Delayed until beta phase (earliest) | ||
prio:important: | ||
color: "B60205" | ||
description: Should be included in next release | ||
prio:rejected: | ||
color: "CE3C0F" | ||
description: Not realistically solvable at this time | ||
|
||
status:confirmed: | ||
color: "c7def8" | ||
description: A developer reproduced this issue | ||
status:duplicate: | ||
color: "c7def8" | ||
description: This problem has already neem reported | ||
status:fixed: | ||
color: "c7def8" | ||
description: This problem has been solved | ||
status:inprogress: | ||
color: "c7def8" | ||
description: Someone is actively working on this | ||
status:norepro: | ||
color: "c7def8" | ||
description: We tried, but we don't know why this happens | ||
status:wontfix: | ||
color: "c7def8" | ||
description: Sorry | ||
|
||
type:bug: | ||
color: "cc317c" | ||
description: Problems in existing behavior | ||
type:documentation: | ||
color: "cc317c" | ||
description: Improvements or additions to documentation | ||
type:enhancement: | ||
color: "cc317c" | ||
description: Improvements to existing behavior | ||
type:feature: | ||
color: "cc317c" | ||
description: Completely new behavior | ||
type:housekeeping: | ||
color: "cc317c" | ||
description: Pull requests that maintain our repository in a clean state | ||
type:rfc: | ||
color: "cc317c" | ||
description: Please provide feedback on this item | ||
type:question: | ||
color: "cc317c" | ||
description: Support; no call to action |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
name: Manage Labels | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
paths: | ||
- ./.github/labels.yml | ||
- ./packages/label-manager/** | ||
workflow_dispatch: | ||
|
||
concurrency: manage-labels | ||
|
||
jobs: | ||
manage-labels: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@master | ||
with: | ||
node-version: 18.x | ||
- run: yarn install | ||
- run: yarn workspace @kitten-science/label-manager tsc --build | ||
|
||
- uses: ./packages/label-manager | ||
with: | ||
repo_token: "${{ secrets.GITHUB_TOKEN }}" |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
554 changes: 280 additions & 274 deletions
554
.yarn/releases/yarn-3.2.4.cjs → .yarn/releases/yarn-3.3.0.cjs
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,5 +48,5 @@ | |
"kittens", | ||
"scientists" | ||
], | ||
"packageManager": "yarn@3.2.4" | ||
"packageManager": "yarn@3.3.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
name: "KS Label Manager" | ||
description: "Manages labels on the Kitten Science repositories." | ||
author: "Oliver Salzburg" | ||
inputs: | ||
repo_token: | ||
required: true | ||
description: Needs `secrets.GITHUB_TOKEN` to talk to the API. | ||
runs: | ||
using: "node16" | ||
main: "output/main.js" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"private": true, | ||
"name": "@kitten-science/label-manager", | ||
"version": "latest", | ||
"description": "Manages the labels on this GitHub repository.", | ||
"license": "MIT", | ||
"author": "Oliver Salzburg <oliver.salzburg@gmail.com>", | ||
"homepage": "https://github.com/kitten-science/kitten-scientists", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/kitten-science/kitten-scientists.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/kitten-science/kitten-scientists/issues" | ||
}, | ||
"dependencies": { | ||
"@actions/core": "1.10.0", | ||
"@actions/github": "5.1.1", | ||
"tslib": "2.4.1", | ||
"yaml": "2.1.3" | ||
}, | ||
"devDependencies": { | ||
"@types/node": "18.11.9", | ||
"typescript": "4.9.3" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
import * as core from "@actions/core"; | ||
import * as github from "@actions/github"; | ||
import fs from "node:fs/promises"; | ||
import YAML from "yaml"; | ||
|
||
async function run(): Promise<void> { | ||
try { | ||
if (!process.env.GITHUB_REPOSITORY) { | ||
throw new Error("Missing GITHUB_REPOSITORY"); | ||
} | ||
|
||
const [repoOwner, repoName] = process.env.GITHUB_REPOSITORY.split("/"); | ||
const repoToken = core.getInput("repo_token"); | ||
|
||
const labelsYaml = await fs.readFile(".github/labels.yml", "utf8"); | ||
const config = YAML.parse(labelsYaml) as { | ||
labels: Record<string, { color?: string; description?: string }>; | ||
}; | ||
|
||
core.debug("Configured labels:"); | ||
for (const [name, label] of Object.entries(config.labels)) { | ||
core.debug(name); | ||
if (label.color) { | ||
core.debug(` Color: ${label.color}`); | ||
} | ||
if (label.description) { | ||
core.debug(` Descr: ${label.description}`); | ||
} | ||
} | ||
|
||
const octokit = github.getOctokit(repoToken); | ||
|
||
const existingLabels = await octokit.rest.issues.listLabelsForRepo({ | ||
owner: repoOwner, | ||
repo: repoName, | ||
}); | ||
|
||
core.info("Updating labels..."); | ||
const labelResults = { | ||
created: new Array<string>(), | ||
updated: new Array<string>(), | ||
}; | ||
|
||
for (const [name, label] of Object.entries(config.labels)) { | ||
const existingLabel = existingLabels.data.find(existing => existing.name === name); | ||
if (existingLabel) { | ||
if ( | ||
existingLabel.color === label.color && | ||
existingLabel.description === (label.description ?? null) | ||
) { | ||
core.info(`Label '${name}' is up-to-date. Skipping.`); | ||
continue; | ||
} | ||
|
||
core.notice(`Label '${name}' exists with different attributes. Updating...`); | ||
existingLabel.color = label.color ?? "888888"; | ||
existingLabel.description = label.description ?? null; | ||
await octokit.rest.issues.updateLabel({ | ||
color: label.color, | ||
description: label.description, | ||
name: existingLabel.name, | ||
owner: repoOwner, | ||
repo: repoName, | ||
}); | ||
continue; | ||
} | ||
|
||
core.notice(`Creating new label '${name}'...`); | ||
await octokit.rest.issues.createLabel({ | ||
color: label.color, | ||
description: label.description, | ||
name: name, | ||
owner: repoOwner, | ||
repo: repoName, | ||
}); | ||
labelResults.created.push(name); | ||
} | ||
|
||
for (const label of existingLabels.data) { | ||
const labelIsConfigured = Object.keys(config.labels).includes(label.name); | ||
if (!labelIsConfigured) { | ||
core.notice(`Label '${label.name}' is not configured in labels.yml. It should be deleted.`); | ||
} | ||
} | ||
|
||
core.setOutput("label_created", labelResults.created); | ||
core.setOutput("label_updated", labelResults.updated); | ||
|
||
core.info("Done."); | ||
} catch (error) { | ||
if (error instanceof Error) core.setFailed(error.message); | ||
} | ||
} | ||
|
||
void run(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"extends": "../../tsconfig.json", | ||
"compilerOptions": { | ||
"module": "commonjs", | ||
"outDir": "output", | ||
"rootDir": "source", | ||
"target": "ES6", | ||
"tsBuildInfoFile": "output/.tsbuildinfo", | ||
"types": ["@types/node"] | ||
}, | ||
"include": ["../../@types", "./source"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.