Updating deps, switching to ncc & adding option to not delete labels

This commit is contained in:
Benjamin Lannon 2021-05-29 11:11:43 -04:00
commit f3fc93acca
8 changed files with 337 additions and 7865 deletions

View file

@ -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
- feat: Updated to JS Actions syntax. Removed Dockerfile and switched to action.yml with bundled version of package using parcel

View file

@ -6,7 +6,7 @@ In the repo you'd like to use this, define a JSON file in `.github/labels.json`.
![labels.json file](screenshots/json.png)
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:
@ -30,4 +30,6 @@ jobs:
- uses: lannonbr/issue-label-manager-action@2.0.0
env:
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)
```

View file

@ -7,3 +7,8 @@ runs:
branding:
icon: "upload"
color: "green"
inputs:
delete:
description: "Will not delete any existing labels and will only modify / create them"
required: false
default: false

View file

@ -1,6 +1,7 @@
const fs = require("fs");
const path = require("path");
const github = require("@actions/github");
const core = require('@actions/core')
const accessToken = process.env.GITHUB_TOKEN;
const octokit = new github.GitHub(accessToken);
@ -12,6 +13,10 @@ async function run() {
"labels.json"
);
if (!core.getBooleanInput('delete')) {
console.log('[Action] Will not delete any existing labels')
}
let liveLabels = await getCurrentLabels();
let newLabels = JSON.parse(fs.readFileSync(newLabelsUrl).toString());
@ -31,7 +36,6 @@ async function run() {
name: mod.label.name,
color: mod.label.color,
description: mod.label.description,
previews: ["symmetra"]
};
console.log(`[Action] Creating Label: ${mod.label.name}`);
@ -42,19 +46,20 @@ async function run() {
current_name: mod.label.name,
color: mod.label.color,
description: mod.label.description,
previews: ["symmetra"]
};
console.log(`[Action] Updating Label: ${mod.label.name}`);
await octokit.issues.updateLabel(params);
} else if (mod.type === "delete") {
let params = {
...github.context.repo,
name: mod.label.name
};
console.log(`[Action] Deleting Label: ${mod.label.name}`);
await octokit.issues.deleteLabel(params);
if (core.getBooleanInput('delete')) {
let params = {
...github.context.repo,
name: mod.label.name
};
console.log(`[Action] Deleting Label: ${mod.label.name}`);
await octokit.issues.deleteLabel(params);
}
}
});
}
@ -62,7 +67,6 @@ async function run() {
async function getCurrentLabels() {
let response = await octokit.issues.listLabelsForRepo({
...github.context.repo,
previews: ["symmetra"]
});
let data = response.data;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

7944
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -7,12 +7,13 @@
"author": "Benjamin Lannon <benjamin@lannonbr.com>",
"license": "MIT",
"scripts": {
"build": "parcel build index.js --out-dir lib --target node --bundle-node-modules"
"build": "ncc build index.js -o lib -m"
},
"dependencies": {
"@actions/github": "^1.0.0"
"@actions/github": "^5.0.0",
"@actions/core": "^1.3.0"
},
"devDependencies": {
"parcel-bundler": "1.12.3"
"@vercel/ncc": "^0.28.6"
}
}