Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: log group #39

Merged
merged 9 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/test-dist.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ on:
branches: [develop]
paths:
- dist/index.js
issue_comment:
types: [edited]

jobs:
generator:
if: ${{ !startsWith(github.head_ref, 'release/') }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
15 changes: 13 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -29983,7 +29986,13 @@ 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.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);
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.');
Expand Down Expand Up @@ -30045,6 +30054,7 @@ function renderMarkdown(pullRequestList) {
docs: [],
extra: [],
};
(0, core_1.startGroup)(`[renderer] pullRequestList`);
pullRequestList.forEach((pr) => {
pr.body = pr.body ? pr.body : '';
// 不需要纳入 changelog 的 label
Expand Down Expand Up @@ -30095,6 +30105,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)}` : '',
Expand Down
8 changes: 5 additions & 3 deletions src/generator.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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`
Expand Down
11 changes: 9 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
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)}`)
endGroup()

startGroup(`[base] info`)
info(`eventName:${context.eventName}`)
info(`action:${context.payload.action}`)
endGroup()

// console.log('payload', context.payload);

Expand Down
5 changes: 3 additions & 2 deletions src/renderer.ts
Original file line number Diff line number Diff line change
@@ -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']
Expand Down Expand Up @@ -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 : ''

Expand Down Expand Up @@ -103,6 +103,7 @@ export function renderMarkdown(pullRequestList: PullsData[]) {
categories.extra.push(pr) // ??
}
})
endGroup()

return [
categories.breaking.length ? `### ❗ Breaking Changes\n${renderCate(categories.breaking)}` : '',
Expand Down