Skip to content

[Docs Site] Post build errors as PR comments #46696

[Docs Site] Post build errors as PR comments

[Docs Site] Post build errors as PR comments #46696

Workflow file for this run

name: CI
on:
pull_request:
branches:
- production
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
compile:
name: Compiles
runs-on: ubuntu-latest
defaults:
run:
shell: bash -e {0} 2>> stderr.log
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- uses: actions/setup-node@v4
with:
node-version: 22
cache: "npm"
- uses: actions/cache/restore@v4
with:
path: |
node_modules/.astro
key: static
- run: npm ci
- run: npm run check
- run: npm run format:core:check
## TODO: content formatting checks
- run: npm run build
env:
NODE_OPTIONS: "--max-old-space-size=4192"
RUN_LINK_CHECK: true
- run: npm run check:worker
- uses: actions/cache/save@v4
with:
path: |
node_modules/.astro
key: static
- name: Check - Validate redirects (infinite loops, sources with fragment)
run: npx tsm bin/validate-redirects.ts
- name: Tests
run: npm run test
- name: post build errors as PR comment
if: failure()
run: |
# gh run view ${{ github.run_id }} --repo ${{ github.repository }} --log-failed > logs.txt
# ERRORS=$(cat logs.txt |
# cut -d$'\t' -f3 | # remove workflow/step columns
# cut -d' ' -f2-) # remove timestamp
# sed -n '/\[.*error.*\]/I,$p') # select lines from '[...error...]' or 'npm err' (case-insensitive) to EOF
echo $SHELLOPTS
ls ${{ github.workspace }}
cat ${{ github.workspace }}/stderr.log
if [ -s "stderr.log" ]; then
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token
URL=$(gh run view ${{ github.run_id }} --json url --jq '.url')
BODY="[Build failed]($URL)\n\n\`\`\`txt\n$(cat stderr.log)\n\`\`\`"
gh pr comment ${{ github.event.number }} --repo ${{ github.repository }} --body $BODY
fi