Skip to content

Commit 9eba995

Browse files
committed
[Docs Site] Post build errors as PR comments
1 parent 97f12e9 commit 9eba995

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
compile:
1414
name: Compiles
1515
runs-on: ubuntu-latest
16+
defaults:
17+
run:
18+
shell: bash -e {0} 2> >(tee -a stderr.log >&2)
1619
steps:
1720
- uses: actions/checkout@v4
1821
with:
@@ -50,3 +53,21 @@ jobs:
5053

5154
- name: Tests
5255
run: npm run test
56+
57+
- name: post build errors as PR comment
58+
if: failure()
59+
run: |
60+
# gh run view ${{ github.run_id }} --repo ${{ github.repository }} --log-failed > logs.txt
61+
# ERRORS=$(cat logs.txt |
62+
# cut -d$'\t' -f3 | # remove workflow/step columns
63+
# cut -d' ' -f2-) # remove timestamp
64+
# sed -n '/\[.*error.*\]/I,$p') # select lines from '[...error...]' or 'npm err' (case-insensitive) to EOF
65+
66+
if [ -s "stderr.log" ]; then
67+
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
68+
69+
URL=$(gh run view ${{ github.run_id }} --json url --jq '.url')
70+
BODY="[Build failed]($URL)\n\n\`\`\`txt\n$(cat stderr.log)\n\`\`\`"
71+
72+
gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body $BODY
73+
fi

astro.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ export default defineConfig({
174174
"./src/title.css",
175175
"./src/tooltips.css",
176176
],
177-
pagination: false,
177+
pagination: "test",
178178
plugins: [
179179
...(runLinkCheck
180180
? [

0 commit comments

Comments
 (0)