2.0.0 release (#8)

* Upgrading action to JS Action

* Swapping to double-quotes for strings

* Switching parcel bundle to target node

* Updating docs
This commit is contained in:
Benjamin Lannon 2019-08-25 21:51:08 -04:00 committed by GitHub
commit 56bf52020f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 7752 additions and 169 deletions

3
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules node_modules
.cache

11
CHANGELOG.md Normal file
View 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

View file

@ -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"]

View file

@ -1,4 +1,4 @@
Copyright 2018 Benjamin Lannnon Copyright 2018-2019 Benjamin Lannnon
Permission is hereby granted, free of charge, to any person obtaining a copy of this Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software software and associated documentation files (the "Software"), to deal in the Software

View file

@ -18,9 +18,10 @@ If a label doesn't need a description, leave out the `description` field of the
This action only needs the GITHUB_TOKEN secret as it interacts with the GitHub API to modify labels. The action can be used as such: This action only needs the GITHUB_TOKEN secret as it interacts with the GitHub API to modify labels. The action can be used as such:
```hcl ```yaml
action "Update Label" { steps:
uses = "lannonbr/issue-label-manager-action@master" - name: "Check & Modify Labels"
secrets = ["GITHUB_TOKEN"] uses: lannonbr/issue-label-manager-action@2.0.0
} env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
``` ```

9
action.yml Normal file
View 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"

View file

@ -1,8 +1,9 @@
const { Toolkit } = require("actions-toolkit");
const fs = require("fs"); const fs = require("fs");
const path = require("path"); const path = require("path");
const tools = new Toolkit(); const github = require("@actions/github");
const octokit = tools.createOctokit();
const accessToken = process.env.GITHUB_TOKEN;
const octokit = new github.GitHub(accessToken);
async function run() { async function run() {
let newLabelsUrl = path.join( let newLabelsUrl = path.join(
@ -25,29 +26,32 @@ async function run() {
labelModList.forEach(async mod => { labelModList.forEach(async mod => {
if (mod.type === "create") { if (mod.type === "create") {
let params = tools.context.repo({ let params = {
...github.context.repo,
name: mod.label.name, name: mod.label.name,
color: mod.label.color, color: mod.label.color,
description: mod.label.description, description: mod.label.description,
headers: { accept: "application/vnd.github.symmetra-preview+json" } previews: ["symmetra"]
}); };
console.log(`[Action] Creating Label: ${mod.label.name}`); console.log(`[Action] Creating Label: ${mod.label.name}`);
await octokit.issues.createLabel(params); await octokit.issues.createLabel(params);
} else if (mod.type === "update") { } else if (mod.type === "update") {
let params = tools.context.repo({ let params = {
...github.context.repo,
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,
headers: { accept: "application/vnd.github.symmetra-preview+json" } 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") {
let params = tools.context.repo({ let params = {
...github.context.repo,
name: mod.label.name name: mod.label.name
}); };
console.log(`[Action] Deleting Label: ${mod.label.name}`); console.log(`[Action] Deleting Label: ${mod.label.name}`);
await octokit.issues.deleteLabel(params); await octokit.issues.deleteLabel(params);
@ -56,11 +60,10 @@ async function run() {
} }
async function getCurrentLabels() { async function getCurrentLabels() {
let response = await octokit.issues.listLabelsForRepo( let response = await octokit.issues.listLabelsForRepo({
tools.context.repo({ ...github.context.repo,
headers: { accept: "application/vnd.github.symmetra-preview+json" } previews: ["symmetra"]
}) });
);
let data = response.data; let data = response.data;
return data; return data;

204
lib/index.js Normal file

File diff suppressed because one or more lines are too long

1
lib/index.js.map Normal file

File diff suppressed because one or more lines are too long

7615
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -1,13 +1,18 @@
{ {
"name": "issue-label-manager-action", "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", "description": "Will update repo's labels based on data in JSON file located at $REPO/.github/labels.json",
"main": "index.js", "main": "index.js",
"scripts": {},
"keywords": [], "keywords": [],
"author": "Benjamin Lannon <benjamin@lannonbr.com>", "author": "Benjamin Lannon <benjamin@lannonbr.com>",
"license": "MIT", "license": "MIT",
"scripts": {
"build": "parcel build index.js --out-dir lib --target node --bundle-node-modules"
},
"dependencies": { "dependencies": {
"actions-toolkit": "0.0.4" "@actions/github": "^1.0.0"
},
"devDependencies": {
"parcel-bundler": "1.12.3"
} }
} }