Skip to content

Post-Pipeline: Push commit info to Readit

Terminal window
# Required env vars
# READIT_TOKEN=<personal or CI secret>
# READIT_SPACE=<your space/org or username>
# READIT_SLUG=<readit slug, e.g. code-review>
# READIT_API=https://readit.md/api/v1
COMMIT_SHA="${GITHUB_SHA:-$(git rev-parse HEAD)}"
COMMIT_MSG="$(git log -1 --pretty=%B)"
COMMIT_AUTHOR="$(git log -1 --pretty=%an)"
COMMIT_URL="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/commit/${COMMIT_SHA}"
# Example payload: append a new entry to changelog.md (or create if missing)
cat > payload.json <<'JSON'
{
"action": "append", // "append" | "upsert" | "replace"
"target_file": "changelog.md", // where to write
"heading": "## Commit Log", // optional: ensure section exists
"content": ""
}
JSON
# Inject dynamic values
CONTENT="### ${COMMIT_SHA:0:7}${COMMIT_MSG//$'\n'/ }
- Author: ${COMMIT_AUTHOR}
- Link: ${COMMIT_URL}
- Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)
"
# Update JSON "content" field
python - <<PY
import json
p=json.load(open('payload.json'))
p["content"] = """$CONTENT"""
json.dump(p, open('payload.json','w'))
PY
curl -sS -X POST \
-H "Authorization: Bearer $READIT_TOKEN" \
-H "Content-Type: application/json" \
-d @payload.json \
"$READIT_API/readits/$READIT_SPACE/$READIT_SLUG/files"

Notes

  • action can be append (add at end/under heading), upsert (create or update a block keyed by commit), or replace (overwrite file).

  • If you support section targets, you can add “section”: ”## Commit Log” instead of heading.


name: CI
on:
push:
branches: [ main ]
jobs:
build-and-doc:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build & Test
run: |
echo "Run your build/test here"
- name: AI Review (optional)
run: |
curl -sS "https://readit.md/${{ secrets.READIT_TOKEN }}/code-review?q=${{ github.sha }}"
- name: Append commit info to Readit
if: ${{ success() }}
env:
READIT_TOKEN: ${{ secrets.READIT_TOKEN }}
READIT_SPACE: your-space-or-username
READIT_SLUG: code-review
READIT_API: https://readit.md/api/v1
run: |
COMMIT_SHA="${{ github.sha }}"
COMMIT_MSG="${{ github.event.head_commit.message }}"
COMMIT_AUTHOR="${{ github.actor }}"
COMMIT_URL="${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}"
cat > payload.json <<'JSON'
{
"action": "append",
"target_file": "changelog.md",
"heading": "## Commit Log",
"content": ""
}
JSON
CONTENT="### ${COMMIT_SHA:0:7} — ${COMMIT_MSG//$'\n'/ }
- Author: ${COMMIT_AUTHOR}
- Link: ${COMMIT_URL}
- Date: $(date -u +%Y-%m-%dT%H:%M:%SZ)
"
python - <<'PY'
import json, os
p=json.load(open('payload.json'))
p["content"] = os.environ["CONTENT"]
json.dump(p, open('payload.json','w'))
PY
curl -sS -X POST \
-H "Authorization: Bearer $READIT_TOKEN" \
-H "Content-Type: application/json" \
-d @payload.json \
"$READIT_API/readits/$READIT_SPACE/$READIT_SLUG/files"

If you prefer one file per commit:

Terminal window
curl -sS -X POST \
-H "Authorization: Bearer $READIT_TOKEN" \
-H "Content-Type: application/json" \
-d @- "$READIT_API/readits/$READIT_SPACE/$READIT_SLUG/files" <<JSON
{
"action": "upsert",
"target_file": "commits/${COMMIT_SHA}.md",
"content": "# Commit ${COMMIT_SHA}\n\n**Message:** ${COMMIT_MSG}\n\n**Author:** ${COMMIT_AUTHOR}\n\n**Link:** ${COMMIT_URL}\n\n**Date:** $(date -u +%Y-%m-%dT%H:%M:%SZ)\n"
}
JSON

Add a small index file that transcludes the log or the per-commit files, so your reviewers can call:

https://readit.md/${READIT_TOKEN}/${READIT_SLUG}?q=commit:ABC123

index.md (example)

# Code Review Hub
- See the running log in [changelog.md](./changelog.md)
- Or browse [commits/](./commits/)