Skip to content

setup

setup #2

name: CodeState PR Report
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:
jobs:
pr-report:
name: Generate PR Code Report
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

Check failure on line 14 in .github/workflows/codestate-pr-report.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/codestate-pr-report.yml

Invalid workflow file

You have an error in your yaml syntax on line 14
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Generate PR report
env:
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.sha }}
run: |
python tools/codestate_pr_report.py
- name: Build Pages content
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_SHA: ${{ github.sha }}
run: |
set -e
SHORT_SHA=$(git rev-parse --short "$GITHUB_SHA")
OUTDIR="site"
mkdir -p "$OUTDIR"
# Decide sub path
if [ -n "$PR_NUMBER" ]; then
SUBPATH="reports/pr-${PR_NUMBER}/sha-${SHORT_SHA}"
else
SUBPATH="reports/manual/sha-${SHORT_SHA}"
fi
mkdir -p "$OUTDIR/$SUBPATH"
# Copy report as index.html for direct open
if [ -f codestate_pr_report.html ]; then
cp codestate_pr_report.html "$OUTDIR/$SUBPATH/index.html"
else
echo "<html><body><h3>No report found</h3></body></html>" > "$OUTDIR/$SUBPATH/index.html"
fi
# Copy JSON for programmatic access
if [ -f codestate_pr_report.json ]; then
cp codestate_pr_report.json "$OUTDIR/$SUBPATH/codestate_pr_report.json"
fi
# Minimal landing index pointing to this run's page
cat > "$OUTDIR/index.html" << 'HTML'
<!doctype html>
<html lang="en"><head><meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>CodeState Reports</title>
<style>body{font-family:system-ui,Segoe UI,Roboto,Helvetica,Arial,sans-serif;padding:24px;line-height:1.5}a{color:#2563eb}</style>
</head><body>
<h2>CodeState PR Reports</h2>
<p>This site hosts the latest generated PR report for this run.</p>
<p><a id="runLink" href="SUBPATH_PLACEHOLDER/">Open this run's report</a></p>
<p>Looking for older runs? Use the URL pattern: <code>/reports/pr-&lt;number&gt;/sha-&lt;short&gt;/</code></p>
</body></html>
HTML
# Inject subpath
sed -i "s|SUBPATH_PLACEHOLDER|$SUBPATH|g" "$OUTDIR/index.html"
- name: Publish to gh-pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./site
keep_files: true
- name: Upload HTML artifact
uses: actions/upload-artifact@v4
with:
name: codestate-pr-report
path: |
codestate_pr_report.html
codestate_pr_report.json
if-no-files-found: warn
- name: Create or update PR comment
uses: marocchino/sticky-pull-request-comment@v2
with:
header: codestate-pr-report
path: codestate_pr_report.md