From 67b43d3ed26e2c990428aabe8f10ac45df345d59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:10:59 +0800 Subject: [PATCH 1/9] chore: log group --- .github/workflows/test-dist.yaml | 33 ++++++++++++++++---------------- dist/index.js | 6 +++++- src/index.ts | 8 ++++++-- 3 files changed, 28 insertions(+), 19 deletions(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index edf0539..4bad154 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -7,19 +7,20 @@ on: jobs: generator: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: changelog - uses: ./ - id: changelog - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag: 666.666.666.666 - - name: Add comment - uses: peter-evans/create-or-update-comment@v4 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - ${{ steps.changelog.outputs.changelog }} + if: '! startsWith(github.head_ref, ''release/'')' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: changelog + uses: ./ + id: changelog + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: 666.666.666.666 + - name: Add comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + ${{ steps.changelog.outputs.changelog }} diff --git a/dist/index.js b/dist/index.js index f3cfa74..5829d20 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29983,7 +29983,11 @@ const core_1 = __nccwpck_require__(4708); const github_1 = __nccwpck_require__(3802); const generator_1 = __nccwpck_require__(2965); const GITHUB_TOKEN = node_process_1.default.env.GITHUB_TOKEN; -(0, core_1.info)(`github.context:${JSON.stringify(github_1.context)}`); +(0, core_1.startGroup)(`[base] github.context`); +(0, core_1.info)(`context:${JSON.stringify(github_1.context)}`); +(0, core_1.info)(`eventName:${github_1.context.payload.eventName}`); +(0, core_1.info)(`action:${github_1.context.payload.action}`); +(0, core_1.endGroup)(); // console.log('payload', context.payload); if (!GITHUB_TOKEN) { throw new Error('GitHub\'s API requires a token. Please pass a valid token (GITHUB_TOKEN) as an env variable, no scopes are required.'); diff --git a/src/index.ts b/src/index.ts index c649d67..4520f71 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,14 @@ import process from 'node:process' -import { info, setFailed } from '@actions/core' +import { endGroup, info, setFailed, startGroup } from '@actions/core' import { context } from '@actions/github' import { generatorLogStart } from './generator' const GITHUB_TOKEN = process.env.GITHUB_TOKEN -info(`github.context:${JSON.stringify(context)}`) +startGroup(`[base] github.context`) +info(`context:${JSON.stringify(context)}`) +info(`eventName:${context.payload.eventName}`) +info(`action:${context.payload.action}`) +endGroup() // console.log('payload', context.payload); From c1949ec638d8fcaa346cb4f85611257e79c1e7bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:12:46 +0800 Subject: [PATCH 2/9] chore: fix ci --- .github/workflows/test-dist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index 4bad154..a5b5f99 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -7,7 +7,7 @@ on: jobs: generator: - if: '! startsWith(github.head_ref, ''release/'')' + if: '! startsWith(github.head_ref, "release/")' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 0c9abca0e12c752795cce197ecf0523dc4c4fdc4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:19:39 +0800 Subject: [PATCH 3/9] chore: fix ci --- .github/workflows/test-dist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index a5b5f99..fd7bf54 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -7,7 +7,7 @@ on: jobs: generator: - if: '! startsWith(github.head_ref, "release/")' + if: startsWith(github.head_ref, 'release/') != true runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 7052c10862b32f9eeec744d81ad4bf37c5109145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:21:37 +0800 Subject: [PATCH 4/9] chore: fix ci --- .github/workflows/test-dist.yaml | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index fd7bf54..617d8e2 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -7,20 +7,20 @@ on: jobs: generator: - if: startsWith(github.head_ref, 'release/') != true - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: changelog - uses: ./ - id: changelog - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - tag: 666.666.666.666 - - name: Add comment - uses: peter-evans/create-or-update-comment@v4 - with: - issue-number: ${{ github.event.pull_request.number }} - body: | - ${{ steps.changelog.outputs.changelog }} + if: startsWith(github.head_ref, 'release/') != true + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: changelog + uses: ./ + id: changelog + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag: 666.666.666.666 + - name: Add comment + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ github.event.pull_request.number }} + body: | + ${{ steps.changelog.outputs.changelog }} From 02d464444b6d8e784d113d8a75a7f9df7cbebb61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:27:09 +0800 Subject: [PATCH 5/9] chore: fix ci --- .github/workflows/test-dist.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index 617d8e2..5147f04 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -7,7 +7,7 @@ on: jobs: generator: - if: startsWith(github.head_ref, 'release/') != true + if: ${{ !startsWith(github.head_ref, 'release/') }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 From 9ee500296abd63b8292c46932a0f739b348782e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:36:36 +0800 Subject: [PATCH 6/9] chore: wip --- dist/index.js | 4 +++- src/index.ts | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 5829d20..7f4bb72 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29985,7 +29985,9 @@ const generator_1 = __nccwpck_require__(2965); const GITHUB_TOKEN = node_process_1.default.env.GITHUB_TOKEN; (0, core_1.startGroup)(`[base] github.context`); (0, core_1.info)(`context:${JSON.stringify(github_1.context)}`); -(0, core_1.info)(`eventName:${github_1.context.payload.eventName}`); +(0, core_1.endGroup)(); +(0, core_1.startGroup)(`[base] info`); +(0, core_1.info)(`eventName:${github_1.context.eventName}`); (0, core_1.info)(`action:${github_1.context.payload.action}`); (0, core_1.endGroup)(); // console.log('payload', context.payload); diff --git a/src/index.ts b/src/index.ts index 4520f71..d744e0f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,7 +6,10 @@ import { generatorLogStart } from './generator' const GITHUB_TOKEN = process.env.GITHUB_TOKEN startGroup(`[base] github.context`) info(`context:${JSON.stringify(context)}`) -info(`eventName:${context.payload.eventName}`) +endGroup() + +startGroup(`[base] info`) +info(`eventName:${context.eventName}`) info(`action:${context.payload.action}`) endGroup() From 7d623085988711df740b794e33e87e19fccf0ff0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:38:41 +0800 Subject: [PATCH 7/9] chore: wip --- .github/workflows/test-dist.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test-dist.yaml b/.github/workflows/test-dist.yaml index 5147f04..85622a9 100644 --- a/.github/workflows/test-dist.yaml +++ b/.github/workflows/test-dist.yaml @@ -4,6 +4,8 @@ on: branches: [develop] paths: - dist/index.js + issue_comment: + types: [edited] jobs: generator: From e300644825549b4f7402d176e8fe1de3a6d50cab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Tue, 22 Oct 2024 23:59:58 +0800 Subject: [PATCH 8/9] chore: log group --- dist/index.js | 2 ++ src/renderer.ts | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/dist/index.js b/dist/index.js index 7f4bb72..c548ca2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -30051,6 +30051,7 @@ function renderMarkdown(pullRequestList) { docs: [], extra: [], }; + (0, core_1.startGroup)(`[renderer] pullRequestList`); pullRequestList.forEach((pr) => { pr.body = pr.body ? pr.body : ''; // 不需要纳入 changelog 的 label @@ -30101,6 +30102,7 @@ function renderMarkdown(pullRequestList) { categories.extra.push(pr); // ?? } }); + (0, core_1.endGroup)(); return [ categories.breaking.length ? `### ❗ Breaking Changes\n${renderCate(categories.breaking)}` : '', categories.features.length ? `### 🚀 Features\n${renderCate(categories.features)}` : '', diff --git a/src/renderer.ts b/src/renderer.ts index f403c08..d815df3 100644 --- a/src/renderer.ts +++ b/src/renderer.ts @@ -1,5 +1,5 @@ import type { PRChangelog, PullsData } from './types' -import { info } from '@actions/core' +import { endGroup, info, startGroup } from '@actions/core' const skipChangelogLabel = ['skip-changelog'] const fixLabel = ['fix', 'bug', 'hotfix'] @@ -43,7 +43,7 @@ export function renderMarkdown(pullRequestList: PullsData[]) { docs: [] as PRChangelog[], extra: [] as PRChangelog[], } - + startGroup(`[renderer] pullRequestList`) pullRequestList.forEach((pr) => { pr.body = pr.body ? pr.body : '' @@ -103,6 +103,7 @@ export function renderMarkdown(pullRequestList: PullsData[]) { categories.extra.push(pr) // ?? } }) + endGroup() return [ categories.breaking.length ? `### ❗ Breaking Changes\n${renderCate(categories.breaking)}` : '', From 263089faf2427dd09b17b64f1e32fec698a613d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E4=BC=9F=E6=9D=B0?= <674416404@qq.com> Date: Wed, 23 Oct 2024 00:03:47 +0800 Subject: [PATCH 9/9] chore: log group --- dist/index.js | 5 ++++- src/generator.ts | 8 +++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dist/index.js b/dist/index.js index c548ca2..15c5a88 100644 --- a/dist/index.js +++ b/dist/index.js @@ -29954,7 +29954,10 @@ function generatorLogStart(context) { const PRNumbers = (0, renderer_1.getPullNumbers)(releases.data.body); const PRListRes = yield Promise.all(PRNumbers.map(pull_number => getPullRequest(owner, repo, pull_number))); const PRList = PRListRes.map(res => res.data); - (0, core_1.info)(`PRList:${JSON.stringify(PRList)}`); + (0, core_1.startGroup)(`[generator] PRList`); + (0, core_1.info)(`PRList count:${PRList.length}`); + (0, core_1.info)(`PRList json:${JSON.stringify(PRList)}`); + (0, core_1.endGroup)(); const logRelease = `(删除此行代表确认该日志): 修改并确认日志后删除这一行,机器人会提交到 本 PR 的 CHANGELOG.md 文件中 ## 🌈 ${tag} \`${(0, dayjs_1.default)().format('YYYY-MM-DD')}\` \n${(0, renderer_1.renderMarkdown)(PRList)}\n`; (0, core_1.info)(logRelease); diff --git a/src/generator.ts b/src/generator.ts index 46a18af..8a600aa 100644 --- a/src/generator.ts +++ b/src/generator.ts @@ -1,7 +1,7 @@ import type { PullsData } from './types' import { readFileSync } from 'node:fs' import process from 'node:process' -import { getInput, info, setOutput } from '@actions/core' +import { endGroup, getInput, info, setOutput, startGroup } from '@actions/core' import dayjs from 'dayjs' import { getPullNumbers, renderMarkdown } from './renderer' import { useOctokit } from './useOctokit' @@ -33,8 +33,10 @@ export async function generatorLogStart(context) { ))) const PRList = PRListRes.map(res => res.data as PullsData) - - info(`PRList:${JSON.stringify(PRList)}`) + startGroup(`[generator] PRList`) + info(`PRList count:${PRList.length}`) + info(`PRList json:${JSON.stringify(PRList)}`) + endGroup() const logRelease = `(删除此行代表确认该日志): 修改并确认日志后删除这一行,机器人会提交到 本 PR 的 CHANGELOG.md 文件中 ## 🌈 ${tag} \`${dayjs().format('YYYY-MM-DD')}\` \n${renderMarkdown(PRList)}\n`