From 6ef7f5ec5b36444c33a9dcd30414a8e7eed7fc4f Mon Sep 17 00:00:00 2001 From: Jan Kaifer Date: Fri, 13 Jan 2023 11:29:09 +0100 Subject: [PATCH] port `type: needs investigation` into linear (#44823) Port it to Linear whenever we need investigation more investigation. Tested on my fork. --- .github/actions/issue-auto-label/index.js | 30 +++++++++++-------- .github/actions/issue-auto-label/src/index.ts | 8 +++-- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/.github/actions/issue-auto-label/index.js b/.github/actions/issue-auto-label/index.js index 2b695c3b095a..a935d86e5f5b 100644 --- a/.github/actions/issue-auto-label/index.js +++ b/.github/actions/issue-auto-label/index.js @@ -52,20 +52,24 @@ Object.defineProperty(p, '__esModule', { value: true }) const s = r(a(5438)) const i = r(a(2186)) - const o = { LINEAR: 'linear', KIND_BUG: 'kind: bug' } + const o = { + LINEAR: 'linear', + KIND_BUG: 'kind: bug', + NEEDS_INVESTIGAGION: 'type: needs investigation', + } + const n = [o.KIND_BUG, o.NEEDS_INVESTIGAGION] async function run() { try { const { payload: e, repo: p } = s.context const { issue: a, - pull_request: d, - label: { name: t }, + label: { name: d }, } = e - if (d || !a?.body || !process.env.GITHUB_TOKEN) return - const r = s.getOctokit(process.env.GITHUB_TOKEN).rest - const i = { ...p, issue_number: a.number } - if (t === o.KIND_BUG) { - r.issues.addLabels({ ...i, labels: [o.LINEAR] }) + if (!a || !process.env.GITHUB_TOKEN) return + const t = s.getOctokit(process.env.GITHUB_TOKEN).rest + const r = { ...p, issue_number: a.number } + if (n.includes(d)) { + t.issues.addLabels({ ...r, labels: [o.LINEAR] }) } } catch (e) { i.setFailed(e.message) @@ -6240,8 +6244,8 @@ AbortError.prototype.constructor = AbortError AbortError.prototype.name = 'AbortError' const A = r.URL || s.URL - const k = d.PassThrough - const N = function isDomainOrSubdomain(e, p) { + const N = d.PassThrough + const k = function isDomainOrSubdomain(e, p) { const a = new A(p).hostname const d = new A(e).hostname return a === d || (a[a.length - d.length - 1] === '.' && a.endsWith(d)) @@ -6374,7 +6378,7 @@ timeout: s.timeout, size: s.size, } - if (!N(s.url, t)) { + if (!k(s.url, t)) { for (const e of [ 'authorization', 'www-authenticate', @@ -6415,7 +6419,7 @@ e.once('end', function () { if (m) m.removeEventListener('abort', v) }) - let d = e.pipe(new k()) + let d = e.pipe(new N()) const t = { url: s.url, status: e.statusCode, @@ -6445,7 +6449,7 @@ return } if (i == 'deflate' || i == 'x-deflate') { - const p = e.pipe(new k()) + const p = e.pipe(new N()) p.once('data', function (e) { if ((e[0] & 15) === 8) { d = d.pipe(o.createInflate()) diff --git a/.github/actions/issue-auto-label/src/index.ts b/.github/actions/issue-auto-label/src/index.ts index 08a5708e6ca6..13de5dd178ce 100644 --- a/.github/actions/issue-auto-label/src/index.ts +++ b/.github/actions/issue-auto-label/src/index.ts @@ -4,23 +4,25 @@ import * as core from '@actions/core' const LABELS = { LINEAR: 'linear', KIND_BUG: 'kind: bug', + NEEDS_INVESTIGAGION: 'type: needs investigation', } +const labelsPortedToLinear = [LABELS.KIND_BUG, LABELS.NEEDS_INVESTIGAGION] + async function run() { try { const { payload, repo } = github.context const { issue, - pull_request, label: { name: newLabel }, } = payload - if (pull_request || !issue?.body || !process.env.GITHUB_TOKEN) return + if (!issue || !process.env.GITHUB_TOKEN) return const client = github.getOctokit(process.env.GITHUB_TOKEN).rest const issueCommon = { ...repo, issue_number: issue.number } - if (newLabel === LABELS.KIND_BUG) { + if (labelsPortedToLinear.includes(newLabel)) { client.issues.addLabels({ ...issueCommon, labels: [LABELS.LINEAR],