mirror of
https://github.com/lannonbr/issue-label-manager-action.git
synced 2025-06-28 06:24:13 +00:00
Updating deps, switching to ncc & adding option to not delete labels
This commit is contained in:
parent
2e07e1d2e6
commit
f3fc93acca
8 changed files with 337 additions and 7865 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
# Unreleased Changes
|
||||||
|
|
||||||
|
- breaking: Switched default behavior to not delete default labels. To enable this, set `delete` input to true.
|
||||||
|
- chore: Moved from parcel to NCC for bundling the code down.
|
||||||
|
- chore: Updated dependencies
|
||||||
|
|
||||||
# 2.0.0 - August 25, 2019
|
# 2.0.0 - August 25, 2019
|
||||||
|
|
||||||
- feat: Updated to JS Actions syntax. Removed Dockerfile and switched to action.yml with bundled version of package using parcel
|
- feat: Updated to JS Actions syntax. Removed Dockerfile and switched to action.yml with bundled version of package using parcel
|
||||||
|
|
|
@ -6,7 +6,7 @@ In the repo you'd like to use this, define a JSON file in `.github/labels.json`.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
Then, set up a workflow that executes this action. When run, it will update the list of labels in the repo to match the JSON file and will delete any other labels.
|
Then, set up a workflow that executes this action. When run, it will update the list of labels in the repo to match the JSON file. If you wish for this to remove any labels not in the JSON file, set the `delete` input to true as shown in the example below.
|
||||||
|
|
||||||
The result of using the labels.json file shown above is as follows:
|
The result of using the labels.json file shown above is as follows:
|
||||||
|
|
||||||
|
@ -30,4 +30,6 @@ jobs:
|
||||||
- uses: lannonbr/issue-label-manager-action@2.0.0
|
- uses: lannonbr/issue-label-manager-action@2.0.0
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
delete: true # will delete any labels that aren't in the .github/labels.json (this is set to false by default)
|
||||||
```
|
```
|
||||||
|
|
|
@ -7,3 +7,8 @@ runs:
|
||||||
branding:
|
branding:
|
||||||
icon: "upload"
|
icon: "upload"
|
||||||
color: "green"
|
color: "green"
|
||||||
|
inputs:
|
||||||
|
delete:
|
||||||
|
description: "Will not delete any existing labels and will only modify / create them"
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
|
10
index.js
10
index.js
|
@ -1,6 +1,7 @@
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const path = require("path");
|
const path = require("path");
|
||||||
const github = require("@actions/github");
|
const github = require("@actions/github");
|
||||||
|
const core = require('@actions/core')
|
||||||
|
|
||||||
const accessToken = process.env.GITHUB_TOKEN;
|
const accessToken = process.env.GITHUB_TOKEN;
|
||||||
const octokit = new github.GitHub(accessToken);
|
const octokit = new github.GitHub(accessToken);
|
||||||
|
@ -12,6 +13,10 @@ async function run() {
|
||||||
"labels.json"
|
"labels.json"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (!core.getBooleanInput('delete')) {
|
||||||
|
console.log('[Action] Will not delete any existing labels')
|
||||||
|
}
|
||||||
|
|
||||||
let liveLabels = await getCurrentLabels();
|
let liveLabels = await getCurrentLabels();
|
||||||
let newLabels = JSON.parse(fs.readFileSync(newLabelsUrl).toString());
|
let newLabels = JSON.parse(fs.readFileSync(newLabelsUrl).toString());
|
||||||
|
|
||||||
|
@ -31,7 +36,6 @@ async function run() {
|
||||||
name: mod.label.name,
|
name: mod.label.name,
|
||||||
color: mod.label.color,
|
color: mod.label.color,
|
||||||
description: mod.label.description,
|
description: mod.label.description,
|
||||||
previews: ["symmetra"]
|
|
||||||
};
|
};
|
||||||
console.log(`[Action] Creating Label: ${mod.label.name}`);
|
console.log(`[Action] Creating Label: ${mod.label.name}`);
|
||||||
|
|
||||||
|
@ -42,12 +46,12 @@ async function run() {
|
||||||
current_name: mod.label.name,
|
current_name: mod.label.name,
|
||||||
color: mod.label.color,
|
color: mod.label.color,
|
||||||
description: mod.label.description,
|
description: mod.label.description,
|
||||||
previews: ["symmetra"]
|
|
||||||
};
|
};
|
||||||
console.log(`[Action] Updating Label: ${mod.label.name}`);
|
console.log(`[Action] Updating Label: ${mod.label.name}`);
|
||||||
|
|
||||||
await octokit.issues.updateLabel(params);
|
await octokit.issues.updateLabel(params);
|
||||||
} else if (mod.type === "delete") {
|
} else if (mod.type === "delete") {
|
||||||
|
if (core.getBooleanInput('delete')) {
|
||||||
let params = {
|
let params = {
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
name: mod.label.name
|
name: mod.label.name
|
||||||
|
@ -56,13 +60,13 @@ async function run() {
|
||||||
|
|
||||||
await octokit.issues.deleteLabel(params);
|
await octokit.issues.deleteLabel(params);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCurrentLabels() {
|
async function getCurrentLabels() {
|
||||||
let response = await octokit.issues.listLabelsForRepo({
|
let response = await octokit.issues.listLabelsForRepo({
|
||||||
...github.context.repo,
|
...github.context.repo,
|
||||||
previews: ["symmetra"]
|
|
||||||
});
|
});
|
||||||
let data = response.data;
|
let data = response.data;
|
||||||
|
|
||||||
|
|
211
lib/index.js
211
lib/index.js
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
7916
package-lock.json
generated
7916
package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -7,12 +7,13 @@
|
||||||
"author": "Benjamin Lannon <benjamin@lannonbr.com>",
|
"author": "Benjamin Lannon <benjamin@lannonbr.com>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "parcel build index.js --out-dir lib --target node --bundle-node-modules"
|
"build": "ncc build index.js -o lib -m"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@actions/github": "^1.0.0"
|
"@actions/github": "^5.0.0",
|
||||||
|
"@actions/core": "^1.3.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"parcel-bundler": "1.12.3"
|
"@vercel/ncc": "^0.28.6"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue