Skip to content

Commit 9e0c533

Browse files
committed
ci: posting results of linting as sticky PR comment
1 parent 72d2953 commit 9e0c533

File tree

1 file changed

+75
-2
lines changed

1 file changed

+75
-2
lines changed

.github/workflows/lint-readme.yml

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,15 @@ jobs:
2020
uses: actions/checkout@v4
2121

2222
- name: Lint ./gh-cli/README.md
23-
run: node ./.github/scripts/lint-readme.js
23+
id: lint
24+
run: node ./.github/scripts/lint-readme.js | tee gh-cli-readme-lint-results.txt
25+
26+
- name: Upload lint results
27+
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: gh-cli-readme-lint-results
31+
path: gh-cli-readme-lint-results.txt
2432

2533
lint-scripts-readme:
2634
name: Lint ./scripts/README.md
@@ -33,4 +41,69 @@ jobs:
3341
uses: actions/checkout@v4
3442

3543
- name: Lint ./scripts/README.md
36-
run: node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts'
44+
id: lint
45+
run: node ./.github/scripts/lint-readme.js ./scripts '##' '# scripts' | tee scripts-readme-lint-results.txt
46+
47+
- name: Upload lint results
48+
if: steps.lint.outcome == 'failure' || steps.lint.outcome == 'success'
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: scripts-readme-lint-results
52+
path: scripts-readme-lint-results.txt
53+
54+
post-results:
55+
name: Post Lint Results as PR Comment
56+
runs-on: ubuntu-latest
57+
if: always()
58+
needs:
59+
- lint-gh-cli-readme
60+
- lint-scripts-readme
61+
permissions:
62+
pull-requests: write
63+
64+
steps:
65+
- name: Download lint results
66+
uses: actions/download-artifact@v5
67+
with:
68+
path: ./lint-results/
69+
70+
- name: Process Lint Results
71+
id: process-results
72+
run: |
73+
echo "## 📋 README Lint Results" > comment.md
74+
echo "" >> comment.md
75+
76+
# Process gh-cli README results
77+
if [ -f "./lint-results/gh-cli-readme-lint-results.txt" ]; then
78+
echo "### 🚀 gh-cli/README.md" >> comment.md
79+
echo "\`\`\`" >> comment.md
80+
cat "./lint-results/gh-cli-readme-lint-results.txt" >> comment.md
81+
echo "\`\`\`" >> comment.md
82+
echo "" >> comment.md
83+
else
84+
echo "### 🚀 gh-cli/README.md" >> comment.md
85+
echo "❌ No results available" >> comment.md
86+
echo "" >> comment.md
87+
fi
88+
89+
# Process scripts README results
90+
if [ -f "./lint-results/scripts-readme-lint-results.txt" ]; then
91+
echo "### 🔧 scripts/README.md" >> comment.md
92+
echo "\`\`\`" >> comment.md
93+
cat "./lint-results/scripts-readme-lint-results.txt" >> comment.md
94+
echo "\`\`\`" >> comment.md
95+
else
96+
echo "### 🔧 scripts/README.md" >> comment.md
97+
echo "❌ No results available" >> comment.md
98+
fi
99+
100+
echo "" >> comment.md
101+
echo "---" >> comment.md
102+
echo "*Lint results updated at $(date)*" >> comment.md
103+
104+
- name: Post Sticky PR Comment
105+
if: github.event_name == 'pull_request'
106+
uses: marocchino/sticky-pull-request-comment@v2
107+
with:
108+
header: readme-lint-results
109+
path: comment.md

0 commit comments

Comments
 (0)