mirror of
https://github.com/hernikplays/freelo-action.git
synced 2024-11-10 02:38:06 +01:00
fix: don't use Bun API due to NodeJS usage
This commit is contained in:
parent
5001cf119c
commit
ef8d06ba0e
2 changed files with 20 additions and 16 deletions
18
dist/index.js
vendored
18
dist/index.js
vendored
|
@ -45309,6 +45309,7 @@ var axios_default = axios;
|
||||||
|
|
||||||
// src/index.ts
|
// src/index.ts
|
||||||
var import_sanitize_html = __toESM(require_sanitize_html(), 1);
|
var import_sanitize_html = __toESM(require_sanitize_html(), 1);
|
||||||
|
import {readFile} from "node:fs/promises";
|
||||||
var email = core.getInput("email");
|
var email = core.getInput("email");
|
||||||
var apiKey = core.getInput("api-key");
|
var apiKey = core.getInput("api-key");
|
||||||
var projectId = core.getInput("project-id");
|
var projectId = core.getInput("project-id");
|
||||||
|
@ -45348,19 +45349,20 @@ try {
|
||||||
}
|
}
|
||||||
let userPairing;
|
let userPairing;
|
||||||
try {
|
try {
|
||||||
userPairing = (await Bun.file(".github/freelo.txt").text()).split("\n");
|
userPairing = (await readFile("./.github/freelo.txt", { encoding: "utf-8" })).split("\n");
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
console.log("No freelo.txt found in .github folder, skipping");
|
console.log("No freelo.txt found in .github folder, skipping");
|
||||||
}
|
}
|
||||||
if (tasklistId) {
|
if (tasklistId) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "opened": {
|
case "opened": {
|
||||||
const author = userPairing && userPairing.filter((u) => u.includes(issue.user.login)).length > 0 ? `<div><span data-freelo-mention="1" data-freelo-user-id="${userPairing.filter((u) => u.includes(issue.user.login))[0].split(":")[1]}">@${issue.user.login}</span></div>` : `@${issue.user.login}`;
|
const author = userPairing && userPairing.filter((u) => u.includes(issue.user.login)).length > 0 ? `<div><span data-freelo-mention="1" data-freelo-user-id="${userPairing.filter((u) => u.includes(issue.user.login))[0].split(":")[1]}">@${issue.user.login}</span></div>` : `<a href="https://github.com/${issue.user.login}">${issue.user.login}</a>`;
|
||||||
|
console.log(userPairing?.filter((u) => u.includes(issue.user.login)).length);
|
||||||
const taskComment = `
|
const taskComment = `
|
||||||
Created by: ${author}
|
Created by: ${author}<br>
|
||||||
Description: ${import_sanitize_html.default(issue.body ?? "None", sanitizeOptions)}
|
Description: ${import_sanitize_html.default(issue.body ?? "None", sanitizeOptions)}<br>
|
||||||
GitHub issue: <a href="${issue.url}">#${issue.number}</a>
|
GitHub issue: <a href="${issue.url}">#${issue.number}</a><br>
|
||||||
(This action was performed automatically)
|
<i>(This action was performed automatically)</i>
|
||||||
`;
|
`;
|
||||||
const taskContent = {
|
const taskContent = {
|
||||||
name: issue.title,
|
name: issue.title,
|
||||||
|
@ -45381,7 +45383,7 @@ try {
|
||||||
}
|
}
|
||||||
octokit.rest.issues.createComment({
|
octokit.rest.issues.createComment({
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
owner: github.context.payload.repository?.name ?? "",
|
owner: github.context.payload.repository?.owner.login ?? "",
|
||||||
repo: github.context.payload.repository?.name ?? "",
|
repo: github.context.payload.repository?.name ?? "",
|
||||||
body: `Freelo task assigned: <a href="https://app.freelo.io/task/${res.data.id}">${res.data.id}</a><br>Please do not edit or delete this comment as it is used to prevent duplication of tasks.`
|
body: `Freelo task assigned: <a href="https://app.freelo.io/task/${res.data.id}">${res.data.id}</a><br>Please do not edit or delete this comment as it is used to prevent duplication of tasks.`
|
||||||
});
|
});
|
||||||
|
|
18
src/index.ts
18
src/index.ts
|
@ -3,6 +3,7 @@ import { context, getOctokit } from "@actions/github";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import sanitize from "sanitize-html";
|
import sanitize from "sanitize-html";
|
||||||
import type { NewTask } from "./freelo";
|
import type { NewTask } from "./freelo";
|
||||||
|
import { readFile } from "node:fs/promises";
|
||||||
|
|
||||||
// user input
|
// user input
|
||||||
const email = getInput("email");
|
const email = getInput("email");
|
||||||
|
@ -57,8 +58,8 @@ try {
|
||||||
// Load GitHub:Freelo pairing if available
|
// Load GitHub:Freelo pairing if available
|
||||||
let userPairing: string[] | undefined;
|
let userPairing: string[] | undefined;
|
||||||
try {
|
try {
|
||||||
userPairing = (await Bun.file(".github/freelo.txt").text()).split("\n");
|
userPairing = (await readFile("./.github/freelo.txt",{encoding:"utf-8"})).split("\n");
|
||||||
} catch (_) {
|
} catch (e) {
|
||||||
console.log("No freelo.txt found in .github folder, skipping");
|
console.log("No freelo.txt found in .github folder, skipping");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,12 +71,13 @@ try {
|
||||||
userPairing &&
|
userPairing &&
|
||||||
userPairing.filter((u) => u.includes(issue.user.login)).length > 0
|
userPairing.filter((u) => u.includes(issue.user.login)).length > 0
|
||||||
? `<div><span data-freelo-mention="1" data-freelo-user-id="${userPairing.filter((u) => u.includes(issue.user.login))[0].split(":")[1]}">@${issue.user.login}</span></div>`
|
? `<div><span data-freelo-mention="1" data-freelo-user-id="${userPairing.filter((u) => u.includes(issue.user.login))[0].split(":")[1]}">@${issue.user.login}</span></div>`
|
||||||
: `@${issue.user.login}`;
|
: `<a href="https://github.com/${issue.user.login}">${issue.user.login}</a>`;
|
||||||
|
console.log(userPairing?.filter((u) => u.includes(issue.user.login)).length)
|
||||||
const taskComment = `
|
const taskComment = `
|
||||||
Created by: ${author}
|
Created by: ${author}<br>
|
||||||
Description: ${sanitize(issue.body ?? "None", sanitizeOptions)}
|
Description: ${sanitize(issue.body ?? "None", sanitizeOptions)}<br>
|
||||||
GitHub issue: <a href="${issue.url}">#${issue.number}</a>
|
GitHub issue: <a href="${issue.url}">#${issue.number}</a><br>
|
||||||
(This action was performed automatically)
|
<i>(This action was performed automatically)</i>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const taskContent: NewTask = {
|
const taskContent: NewTask = {
|
||||||
|
@ -106,7 +108,7 @@ try {
|
||||||
// create an issue comment so we can track if the task has been already created
|
// create an issue comment so we can track if the task has been already created
|
||||||
octokit.rest.issues.createComment({
|
octokit.rest.issues.createComment({
|
||||||
issue_number: issue.number,
|
issue_number: issue.number,
|
||||||
owner: context.payload.repository?.name ?? "",
|
owner: context.payload.repository?.owner.login ?? "",
|
||||||
repo: context.payload.repository?.name ?? "",
|
repo: context.payload.repository?.name ?? "",
|
||||||
body: `Freelo task assigned: <a href="https://app.freelo.io/task/${res.data.id}">${res.data.id}</a><br>Please do not edit or delete this comment as it is used to prevent duplication of tasks.`,
|
body: `Freelo task assigned: <a href="https://app.freelo.io/task/${res.data.id}">${res.data.id}</a><br>Please do not edit or delete this comment as it is used to prevent duplication of tasks.`,
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue