148 even more doc updates #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 Docs Preview | |
on: | |
pull_request: | |
types: [opened, reopened, synchronize] | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y doxygen graphviz | |
python3 -m pip install --upgrade pip | |
python3 -m pip install mkdocs mkdocs-material pymdown-extensions | |
- name: Build docs (Makefile) | |
run: make clean document | |
- name: Ensure .nojekyll for static assets | |
run: touch site/.nojekyll | |
- name: Deploy PR preview (gh-pages subdir) | |
uses: JamesIves/github-pages-deploy-action@v4 | |
with: | |
branch: gh-pages | |
folder: site | |
target-folder: pr-preview/pr-${{ github.event.number }} | |
clean: true | |
force: false | |
- name: Comment preview URL on PR | |
uses: actions/github-script@v7 | |
env: | |
PREVIEW_URL: https://pecanproject.github.io/sipnet/pr-preview/pr-${{ github.event.number }}/ | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const owner = context.repo.owner; | |
const repo = context.repo.repo; | |
const pr_number = context.payload.pull_request.number; | |
const url = process.env.PREVIEW_URL; | |
const marker = '<!-- pr-preview-url -->'; | |
const body = `${marker}\nPreview: ${url}`; | |
const { data: comments } = await github.rest.issues.listComments({ owner, repo, issue_number: pr_number }); | |
const prev = comments.find(c => (c.body || '').includes(marker)); | |
if (prev) { | |
await github.rest.issues.updateComment({ owner, repo, comment_id: prev.id, body }); | |
} else { | |
await github.rest.issues.createComment({ owner, repo, issue_number: pr_number, body }); | |
} |