-
Notifications
You must be signed in to change notification settings - Fork 440
42 lines (35 loc) · 1.29 KB
/
wrap-issue-details.yaml
File metadata and controls
42 lines (35 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Wrap Issue Content
on:
issues:
types: [opened, edited]
permissions:
contents: read
jobs:
wrap_content:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- uses: actions/github-script@v8
with:
script: |
const body = context.payload.issue.body;
const wrapSection = (inputBody, marker, summary) => {
const regex = new RegExp(`(${marker})\\s*([\\s\\S]*?)(?=\\n### |$)`);
return inputBody.replace(regex, (match, header, content) => {
const trimmed = content.trim();
if (!trimmed || trimmed.includes("<details>")) return match;
return `${header}\n\n<details>\n<summary>${summary}</summary>\n\n${trimmed}\n\n</details>\n`;
});
};
let newBody = body;
newBody = wrapSection(newBody, "### PHP configuration", "phpinfo() output");
newBody = wrapSection(newBody, "### Relevant log output", "Relevant log output");
if (newBody !== body) {
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: newBody
});
}