mirror of
https://github.com/lannonbr/issue-label-manager-action.git
synced 2025-06-28 06:24:13 +00:00
Upgrading action to JS Action
This commit is contained in:
parent
ec1266042a
commit
3f22466aff
9 changed files with 7696 additions and 163 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
node_modules
|
||||
node_modules
|
||||
.cache
|
11
CHANGELOG.md
Normal file
11
CHANGELOG.md
Normal file
|
@ -0,0 +1,11 @@
|
|||
# 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
|
||||
|
||||
# 1.1.0 - February 19, 2019
|
||||
|
||||
- feat: When inserting a color in a hexcode syntax, having a # in front of it will work as expected
|
||||
|
||||
# 1.0.0 - February 11, 2019
|
||||
|
||||
Initial Release
|
19
Dockerfile
19
Dockerfile
|
@ -1,19 +0,0 @@
|
|||
from node:10.14.2-slim
|
||||
|
||||
LABEL version="1.1.0"
|
||||
LABEL repository="https://github/lannonbr/issue-label-manager-action"
|
||||
LABEL maintainer="Benjamin Lannon <benjamin@lannonbr.com>"
|
||||
|
||||
LABEL com.github.actions.name="Issue Label Manager Action"
|
||||
LABEL com.github.actions.description="Will update repo's labels based on data in JSON file located at $REPO/.github/labels.json"
|
||||
LABEL com.github.actions.icon="upload"
|
||||
LABEL com.github.actions.color="green"
|
||||
|
||||
ADD package.json /package.json
|
||||
ADD package-lock.json /package-lock.json
|
||||
WORKDIR /
|
||||
COPY . /
|
||||
|
||||
RUN npm i
|
||||
|
||||
ENTRYPOINT ["node", "/index.js"]
|
9
action.yml
Normal file
9
action.yml
Normal file
|
@ -0,0 +1,9 @@
|
|||
name: 'Issue Label Manager Action'
|
||||
description: 'Will update repo's labels based on data in JSON file located at $REPO/.github/labels.json'
|
||||
author: 'Benjamin Lannon <benjamin@lannonbr.com>'
|
||||
runs:
|
||||
using: 'node12'
|
||||
main: 'lib/index.js'
|
||||
branding:
|
||||
icon: 'upload'
|
||||
color: 'green'
|
35
index.js
35
index.js
|
@ -1,8 +1,9 @@
|
|||
const { Toolkit } = require("actions-toolkit");
|
||||
const fs = require("fs");
|
||||
const path = require("path");
|
||||
const tools = new Toolkit();
|
||||
const octokit = tools.createOctokit();
|
||||
const github = require("@actions/github");
|
||||
|
||||
const accessToken = process.env.GITHUB_TOKEN;
|
||||
const octokit = new github.GitHub(accessToken);
|
||||
|
||||
async function run() {
|
||||
let newLabelsUrl = path.join(
|
||||
|
@ -25,29 +26,32 @@ async function run() {
|
|||
|
||||
labelModList.forEach(async mod => {
|
||||
if (mod.type === "create") {
|
||||
let params = tools.context.repo({
|
||||
let params = {
|
||||
...github.context.repo,
|
||||
name: mod.label.name,
|
||||
color: mod.label.color,
|
||||
description: mod.label.description,
|
||||
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
||||
});
|
||||
previews: ["symmetra"]
|
||||
};
|
||||
console.log(`[Action] Creating Label: ${mod.label.name}`);
|
||||
|
||||
await octokit.issues.createLabel(params);
|
||||
} else if (mod.type === "update") {
|
||||
let params = tools.context.repo({
|
||||
let params = {
|
||||
...github.context.repo,
|
||||
current_name: mod.label.name,
|
||||
color: mod.label.color,
|
||||
description: mod.label.description,
|
||||
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
||||
});
|
||||
previews: ["symmetra"]
|
||||
};
|
||||
console.log(`[Action] Updating Label: ${mod.label.name}`);
|
||||
|
||||
await octokit.issues.updateLabel(params);
|
||||
} else if (mod.type === "delete") {
|
||||
let params = tools.context.repo({
|
||||
let params = {
|
||||
...github.context.repo,
|
||||
name: mod.label.name
|
||||
});
|
||||
};
|
||||
console.log(`[Action] Deleting Label: ${mod.label.name}`);
|
||||
|
||||
await octokit.issues.deleteLabel(params);
|
||||
|
@ -56,11 +60,10 @@ async function run() {
|
|||
}
|
||||
|
||||
async function getCurrentLabels() {
|
||||
let response = await octokit.issues.listLabelsForRepo(
|
||||
tools.context.repo({
|
||||
headers: { accept: "application/vnd.github.symmetra-preview+json" }
|
||||
})
|
||||
);
|
||||
let response = await octokit.issues.listLabelsForRepo({
|
||||
...github.context.repo,
|
||||
previews: ["symmetra"]
|
||||
});
|
||||
let data = response.data;
|
||||
|
||||
return data;
|
||||
|
|
155
lib/index.js
Normal file
155
lib/index.js
Normal file
File diff suppressed because one or more lines are too long
1
lib/index.js.map
Normal file
1
lib/index.js.map
Normal file
File diff suppressed because one or more lines are too long
7615
package-lock.json
generated
7615
package-lock.json
generated
File diff suppressed because it is too large
Load diff
11
package.json
11
package.json
|
@ -1,13 +1,18 @@
|
|||
{
|
||||
"name": "issue-label-manager-action",
|
||||
"version": "1.1.0",
|
||||
"version": "2.0.0",
|
||||
"description": "Will update repo's labels based on data in JSON file located at $REPO/.github/labels.json",
|
||||
"main": "index.js",
|
||||
"scripts": {},
|
||||
"keywords": [],
|
||||
"author": "Benjamin Lannon <benjamin@lannonbr.com>",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"build": "parcel build index.js --out-dir lib"
|
||||
},
|
||||
"dependencies": {
|
||||
"actions-toolkit": "0.0.4"
|
||||
"@actions/github": "^1.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"parcel-bundler": "1.12.3"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue