Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 42 additions & 1 deletion .github/workflows/R.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,9 @@ jobs:
needs: R-CMD-check
permissions:
contents: write # github-pages-deploy-action
pull-requests: write # post PR preview comment
concurrency: # Recommended if you intend to make multiple deployments in quick succession.
group: web-${{ github.workflow }}-${{ github.ref }}
group: web-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -233,6 +234,46 @@ jobs:
single-commit: true
clean: true

- name: Deploy PR preview 🚀
if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: r/docs
target-folder: previews/pr-${{ github.event.pull_request.number }}/r
single-commit: true
clean: true

- name: Comment PR preview link
if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- docs-preview-r-marker -->';
const prNumber = context.issue.number;
const url = `https://multi-objective.github.io/moocore/previews/pr-${prNumber}/r/`;
const body = `${marker}\n📚 [**R docs preview** for this PR](${url})\n\n`;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.data.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}

rchk:
needs: pkgdown
uses: multi-objective/moocore/.github/workflows/rchk.yml@main
34 changes: 34 additions & 0 deletions .github/workflows/docs-preview-cleanup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Cleanup docs preview

on:
pull_request:
types: [closed]

permissions:
contents: write

jobs:
cleanup:
name: Remove docs preview for closed PR
runs-on: ubuntu-latest
# Only run for same-repo PRs; fork PRs never get a preview deployed
if: github.event.pull_request.head.repo.full_name == github.repository
steps:
- uses: actions/checkout@v6
with:
ref: gh-pages

- name: Remove preview folder
run: |
PR_NUMBER="${{ github.event.pull_request.number }}"
PREVIEW_DIR="previews/pr-${PR_NUMBER}"
if [ -d "${PREVIEW_DIR}" ]; then
git rm -rf "${PREVIEW_DIR}"
git config user.email "actions@github.com"
git config user.name "GitHub Actions"
git commit -m "Remove docs preview for PR #${PR_NUMBER}"
git push
echo "Removed ${PREVIEW_DIR}"
else
echo "No preview directory found for PR #${PR_NUMBER}, nothing to clean up"
fi
43 changes: 42 additions & 1 deletion .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,9 @@ jobs:
if: "! contains(github.event.head_commit.message, '[skip ci]')"
permissions:
contents: write
pull-requests: write # post PR preview comment
concurrency: # Recommended if you intend to make multiple deployments in quick succession.
group: web-${{ github.workflow }}-${{ github.ref }}
group: web-${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
timeout-minutes: 10
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -165,6 +166,46 @@ jobs:
single-commit: true
clean: true

- name: Deploy PR preview 🚀
if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: python/doc/_build/html/
target-folder: previews/pr-${{ github.event.pull_request.number }}/python
single-commit: true
clean: true

- name: Comment PR preview link
if: success() && github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
uses: actions/github-script@v7
with:
script: |
const marker = '<!-- docs-preview-python-marker -->';
const prNumber = context.issue.number;
const url = `https://multi-objective.github.io/moocore/previews/pr-${prNumber}/python/`;
const body = `${marker}\n📚 [**Python docs preview** for this PR](${url})\n\n`;
const comments = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
});
const existing = comments.data.find(c => c.body.includes(marker));
if (existing) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existing.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
body,
});
}

coverage:
timeout-minutes: 15
needs: build-doc
Expand Down
Loading