Skip to content

Commit 303d54c

Browse files
thinkallCopilot
andauthored
ci(docs): always trigger docs workflow on PRs; move filtering into workflow (#1544)
* ci(docs): always trigger on PRs, move file filtering into workflow - Drop the `paths` trigger filters so the docs workflow always runs on pull requests (and pushes) and reliably reports its check status. - Add a `changes` job using dorny/paths-filter@v3 to detect doc-related changes inside the workflow with recursive globs (`flaml/**`, `website/**`, `.github/workflows/deploy-website.yml`). - Gate `checks` and `gh-release` on the filter output so the heavy steps are skipped when no doc-related files changed, while `workflow_dispatch` (and `merge_group` for `checks`) can still force a run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci(docs): grant pull-requests:read for dorny/paths-filter, scope contents:write to deploy Address review: dorny/paths-filter@v3 calls the GitHub PR Files API on pull_request events and needs `pull-requests: read`. Without it, the `changes` job can fail with 403 on PRs and block downstream jobs via `needs: changes`. - Drop workflow-level `contents: write`; default to least-privilege `contents: read` and add `pull-requests: read` so the filter can read PR file lists. - Move `contents: write` to the `gh-release` job only, where peaceiris/actions-gh-pages needs it to push to the gh-pages branch. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * ci(docs): keep workflow-level contents:write, only add pull-requests:read Per review feedback, restore `contents: write` at the workflow level (needed by gh-release for peaceiris/actions-gh-pages to push to gh-pages) and just additively grant `pull-requests: read` so dorny/paths-filter@v3 can read PR file lists via the GitHub API. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: thinkall <thinkall@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 51fca27 commit 303d54c

1 file changed

Lines changed: 20 additions & 10 deletions

File tree

.github/workflows/deploy-website.yml

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,35 @@ name: docs
33
on:
44
pull_request:
55
branches: [main]
6-
paths:
7-
- 'flaml/*'
8-
- 'website/*'
9-
- '.github/workflows/deploy-website.yml'
106
push:
117
branches: [main]
12-
paths:
13-
- 'flaml/*'
14-
- 'website/*'
15-
- '.github/workflows/deploy-website.yml'
168
workflow_dispatch:
179
merge_group:
1810
types: [checks_requested]
1911

2012
permissions:
2113
contents: write
14+
pull-requests: read
2215

2316
jobs:
17+
changes:
18+
runs-on: ubuntu-latest
19+
outputs:
20+
docs: ${{ steps.filter.outputs.docs }}
21+
steps:
22+
- uses: actions/checkout@v3
23+
- uses: dorny/paths-filter@v3
24+
id: filter
25+
with:
26+
filters: |
27+
docs:
28+
- 'flaml/**'
29+
- 'website/**'
30+
- '.github/workflows/deploy-website.yml'
31+
2432
checks:
25-
if: github.event_name != 'push'
33+
needs: changes
34+
if: github.event_name != 'push' && (needs.changes.outputs.docs == 'true' || github.event_name == 'workflow_dispatch' || github.event_name == 'merge_group')
2635
runs-on: ubuntu-latest
2736
defaults:
2837
run:
@@ -58,7 +67,8 @@ jobs:
5867
npm run build
5968
fi
6069
gh-release:
61-
if: github.event_name != 'pull_request'
70+
needs: changes
71+
if: github.event_name != 'pull_request' && (needs.changes.outputs.docs == 'true' || github.event_name == 'workflow_dispatch')
6272
runs-on: ubuntu-latest
6373
defaults:
6474
run:

0 commit comments

Comments
 (0)