Skip to content

Commit 7a2c194

Browse files
authored
Update issue-to-markdown.yml
1 parent 0fdc1da commit 7a2c194

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

.github/workflows/issue-to-markdown.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
issues:
55
types: [labeled]
66

7+
permissions:
8+
contents: write
9+
710
jobs:
811
issue_to_markdown:
912
if: contains(github.event.label.name, 'locked')
@@ -15,7 +18,7 @@ jobs:
1518
- name: Convert Issue to Markdown
1619
id: convert
1720
env:
18-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
21+
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
1922
run: |
2023
issue_number=${{ github.event.issue.number }}
2124
curl -s -H "Authorization: token $GITHUB_TOKEN" \
@@ -25,12 +28,18 @@ jobs:
2528
echo "# ${{ github.event.issue.title }}" > issues/issue-$issue_number.md
2629
echo "\n\n${{ github.event.issue.body }}" >> issues/issue-$issue_number.md
2730
echo "\n## Comments" >> issues/issue-$issue_number.md
28-
jq -r '.[] | "\n### \(.user.login) commented:\n \(.body)"' comments.json >> issues/issue-$issue_number.md
31+
cat comments.json
32+
if jq -e . >/dev/null 2>&1 < comments.json; then
33+
jq -r '.[] | "\n### \(.user.login) commented:\n \(.body)"' comments.json >> issues/issue-$issue_number.md
34+
mv comments.json issues/issue-$issue_number-comments.json
35+
else
36+
echo "\nNo comments available." >> issues/issue-$issue_number.md
37+
fi
2938
- name: Commit Markdown
3039
run: |
3140
git config --global user.name 'github-actions'
3241
git config --global user.email 'github-actions@github.com'
33-
git checkout -b feat/capture-issues
42+
git checkout feat/capture-issues
3443
git add issues/
3544
git commit -m "Convert locked issue ${{ github.event.issue.number }} to markdown"
3645
git push origin feat/capture-issues

0 commit comments

Comments
 (0)