First public PR: devcontainer JSON fix + minimal CI guardrails #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: PR summary | ||
| on: | ||
| pull_request: { types: [opened, synchronize, reopened, ready_for_review] } | ||
| permissions: { contents: read, pull-requests: write } | ||
| concurrency: { group: pr-summary-${{ github.ref }}, cancel-in-progress: true } | ||
| jobs: | ||
| summary: | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - uses: actions/checkout@v4 | ||
| with: { fetch-depth: 0 } | ||
| - name: Write step summary | ||
| shell: bash | ||
| run: | | ||
| base="${{ github.base_ref }}"; head="${{ github.sha }}" | ||
| # Ensure local knowledge of the base ref; fetch if missing (tolerate failures) | ||
| if ! git rev-parse --verify "origin/$base" >/dev/null 2>&1; then | ||
| git fetch --no-tags --depth=1 origin "$base" || echo "WARN: could not fetch origin/$base" >&2 | ||
| fi | ||
| changed_count=0 | ||
| docs_count=0 | ||
| file_list="" | ||
| if git rev-parse --verify "origin/$base" >/dev/null 2>&1; then | ||
| base_commit="$(git rev-parse "origin/$base" 2>/dev/null || echo "")" | ||
| if [ -n "$base_commit" ]; then | ||
| # Use diff-tree for robust listing between base and head | ||
| file_list="$(git diff-tree --no-commit-id --name-only -r "$base_commit" "$head" 2>/dev/null || echo "")" | ||
| else | ||
| echo "WARN: empty base commit for origin/$base" >&2 | ||
| fi | ||
| else | ||
| echo "WARN: origin/$base not available; counts default to 0" >&2 | ||
| fi | ||
| if [ -n "$file_list" ]; then | ||
| changed_count="$(printf "%s\n" "$file_list" | sed '/^$/d' | wc -l | tr -d ' ')" | ||
| docs_count="$(printf "%s\n" "$file_list" | grep -E '^content/.*\.md$' | wc -l | tr -d ' ' || true)" | ||
| fi | ||
| { | ||
| echo "## Pull request summary" | ||
| echo "- Changed files: $changed_count" | ||
| echo "- Docs content markdown files (regex ^content/.*\\.md$): $docs_count" | ||
| } >> "$GITHUB_STEP_SUMMARY" | ||
| - name: Comment on PR (non-forks) | ||
| if: ${{ github.event.pull_request.head.repo.fork == false }} | ||
| env: { GH_TOKEN: ${{ github.token }} } | ||
| run: gh pr comment ${{ github.event.pull_request.number }} --body-file "$GITHUB_STEP_SUMMARY" | ||