-
Notifications
You must be signed in to change notification settings - Fork 0
ci: documentation ci #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,14 +1,100 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: Documentation | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull_request: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| types: [opened, synchronize, reopened, closed] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - feature/zensical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - main | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - feature/zensical | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| permissions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pages: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id-token: write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| contents: write # gh-pages + cleanup | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pull-requests: write # PR comments | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| pages: write # deploy-pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| id-token: write # required by deploy-pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| jobs: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| build: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event.action != 'closed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Checkout repository | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/checkout@v6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: "Set up Python" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/setup-python@v6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| python-version-file: "pyproject.toml" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Install uv | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: astral-sh/setup-uv@v7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Sync dependencies | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: uv sync | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Build site | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| run: uv run zensical build --clean | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Deploy PR preview | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: peaceiris/actions-gh-pages@v4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| publish_dir: site | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| destination_dir: pr-${{ github.event.pull_request.number }} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Comment PR with preview URL | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'pull_request' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/github-script@v7 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| script: | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const pr = context.payload.pull_request.number; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { owner, repo } = context.repo; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const url = `https://ff4j.github.io/docs/pr-${pr}/`; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await github.rest.issues.createComment({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| owner, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| repo, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| issue_number: pr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| body: `📘 **Site preview available**:\n\n${url}` | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Upload Pages artifact | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'push' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| uses: actions/upload-pages-artifact@v3 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| with: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: site | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| publish: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| if: github.event_name == 'push' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| runs-on: ubuntu-latest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| needs: build | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| environment: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: github-pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| steps: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| - name: Deploy to GitHub Pages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+74
to
+76
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: github-pages | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| name: github-pages | |
| outputs: | |
| url: ${{ steps.deploy.outputs.page_url }} | |
| steps: | |
| - name: Deploy to GitHub Pages | |
| id: deploy |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cleanup job only runs when a PR is closed without being merged. This means preview folders for merged PRs will remain in the gh-pages branch indefinitely, accumulating over time. Consider also cleaning up preview folders for merged PRs by adjusting the condition to trigger on any PR closure.
| if: github.event_name == 'pull_request' && | |
| github.event.action == 'closed' && | |
| github.event.pull_request.merged == false | |
| if: github.event_name == 'pull_request' && github.event.action == 'closed' |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a version mismatch in the checkout actions. Line 22 uses actions/checkout@v6 for the build job, but line 87 uses actions/checkout@v4 for the cleanup job. This inconsistency could lead to unexpected behavior. Use the same version across the workflow for consistency.
| uses: actions/checkout@v4 | |
| uses: actions/checkout@v6 |
Copilot
AI
Jan 18, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The cleanup step removes the preview folder but doesn't check if the folder exists before attempting to commit. If the folder doesn't exist (e.g., if the workflow was run before this change was implemented), the git commit will be empty. While the "|| exit 0" handles this case, it's better practice to check if the folder exists first and only proceed if it does, to avoid unnecessary git operations.
| - name: Remove PR preview folder | |
| run: | | |
| rm -rf pr-${{ github.event.pull_request.number }} | |
| - name: Commit cleanup | |
| run: | | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| git commit -am "chore: remove preview for PR #${{ github.event.pull_request.number }}" || exit 0 | |
| - name: Remove PR preview folder and commit cleanup | |
| run: | | |
| PR_DIR="pr-${{ github.event.pull_request.number }}" | |
| if [ ! -d "$PR_DIR" ]; then | |
| echo "Preview directory $PR_DIR does not exist; nothing to clean." | |
| exit 0 | |
| fi | |
| rm -rf "$PR_DIR" | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@github.com" | |
| # If there are no changes after removing the directory, skip commit and push | |
| if git diff --quiet; then | |
| echo "No changes to commit after removing $PR_DIR; skipping git commit and push." | |
| exit 0 | |
| fi | |
| git commit -am "chore: remove preview for PR #${{ github.event.pull_request.number }}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR comment step creates a new comment on every push to the PR, which will result in multiple comments cluttering the PR conversation. Consider checking if a preview comment already exists and updating it instead of creating a new one each time. You can search for existing comments and update them, or delete the old one before creating a new one.