Skip to content

Merge branch 'master' into deploy #4

Merge branch 'master' into deploy

Merge branch 'master' into deploy #4

Workflow file for this run

name: Labels
on:
push:
branches:
- deploy
permissions:
issues: write
jobs:
update-labels:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Remove existing labels
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.repo;
while (true) {
const labels = (await github.request("GET /repos/{owner}/{repo}/labels", {
owner,
repo,
headers: {
"X-GitHub-Api-Version": "2022-11-28"
}
})).data;
if (!Array.isArray(labels)) {
throw Error("Expected an array");
}
if (labels.length === 0) {
break;
}
for (const label of labels) {
const name = label.name;
console.log(`Deleting label: ${name}`);
await github.request("DELETE /repos/{owner}/{repo}/labels/{name}", {
owner,
repo,
name,
headers: {
"X-GitHub-Api-Version": "2022-11-28"
}
});
}
}
- name: Create new labels
uses: actions/github-script@v7
with:
script: |
const {owner, repo} = context.repo;
const {colors, labels} = require("./labels.json");
for (const label of labels) {
const {description, name} = label;
const color = label.color || Object.entries(colors).find(c => new RegExp(c[0]).test(name))[1];
console.log(`Creating label: ${name}; color = ${color}; description = ${description}`);
await github.request("POST /repos/{owner}/{repo}/labels", {
owner,
repo,
name,
description,
color,
headers: {
"X-GitHub-Api-Version": "2022-11-28"
}
});
}