Skip to content

Commit 7dd9aa9

Browse files
authored
Avoid persisting docs workflow credentials (#2627)
1 parent 23815bd commit 7dd9aa9

2 files changed

Lines changed: 30 additions & 7 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
run-bench: ${{ steps.plan.outputs.run_bench }}
5252
run-zizmor: ${{ steps.plan.outputs.run_zizmor }}
5353
check-docs: ${{ steps.plan.outputs.check_docs }}
54+
publish-dev-docs: ${{ steps.plan.outputs.publish_dev_docs }}
5455
build-release-binaries: ${{ steps.plan.outputs.build_release_binaries }}
5556
build-docker: ${{ steps.plan.outputs.build_docker }}
5657
steps:
@@ -69,7 +70,7 @@ jobs:
6970
HAS_BUILD_SKIP_DOCKER_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:skip-docker') }}
7071
HAS_BUILD_SKIP_RELEASE_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:skip-release') }}
7172
HAS_BUILD_RELEASE_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'build:release') }}
72-
BASE_SHA: ${{ github.event.pull_request.base.sha }}
73+
BASE_SHA: ${{ github.event.pull_request.base.sha || github.event.before }}
7374
run: |
7475
[[ "$GH_REF" == "refs/heads/master" ]] && on_master_branch=1
7576
[[ "$HAS_SKIP_LABEL" == "true" ]] && has_skip_label=1
@@ -110,8 +111,9 @@ jobs:
110111
[[ ! $has_skip_label && ($any_rust_changed || $bench_related_changed || $on_master_branch) ]] && run_bench=1
111112
[[ ! $has_skip_label && ($workflow_changed || $zizmor_config_changed || $on_master_branch) ]] && run_zizmor=1
112113
[[ ! $has_skip_label && ($docs_related_changed || $on_master_branch) ]] && check_docs=1
113-
[[ ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_release_label && ($release_build_changed || $has_build_release_label) ]] && build_release_binaries=1
114-
[[ ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_docker_label && $docker_build_changed ]] && build_docker=1
114+
[[ $on_master_branch && $docs_related_changed ]] && publish_dev_docs=1
115+
[[ ! $on_master_branch && ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_release_label && ($release_build_changed || $has_build_release_label) ]] && build_release_binaries=1
116+
[[ ! $on_master_branch && ! $has_skip_label && ! $has_build_skip_label && ! $has_build_skip_docker_label && $docker_build_changed ]] && build_docker=1
115117
116118
out() { [[ "$2" ]] && echo "$1=true" || echo "$1=false"; }
117119
{
@@ -120,6 +122,7 @@ jobs:
120122
out run_bench "$run_bench"
121123
out run_zizmor "$run_zizmor"
122124
out check_docs "$check_docs"
125+
out publish_dev_docs "$publish_dev_docs"
123126
out build_release_binaries "$build_release_binaries"
124127
out build_docker "$build_docker"
125128
} >> "${GITHUB_OUTPUT}"
@@ -203,6 +206,19 @@ jobs:
203206
uv run --group docs zensical build
204207
uv run --group docs llmstxt-standalone build
205208
209+
publish-dev-docs:
210+
needs:
211+
- plan
212+
- check-docs
213+
if: ${{ needs.plan.outputs.publish-dev-docs == 'true' }}
214+
permissions:
215+
contents: write
216+
id-token: write
217+
pages: write
218+
uses: ./.github/workflows/publish-docs.yml
219+
with:
220+
plan: ""
221+
206222
build-release-binaries:
207223
needs: plan
208224
if: ${{ needs.plan.outputs.build-release-binaries == 'true' }}
@@ -765,6 +781,7 @@ jobs:
765781
- check-release
766782
- check-zizmor
767783
- check-docs
784+
- publish-dev-docs
768785
- cargo-clippy-linux
769786
- cargo-clippy-windows
770787
- cargo-shear

‎.github/workflows/publish-docs.yml‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
name: Deploy Documentation
22

33
on:
4-
push:
5-
branches:
6-
- master
74
workflow_dispatch:
85
inputs:
96
ref:
@@ -36,6 +33,7 @@ jobs:
3633
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
3734
with:
3835
fetch-depth: 0
36+
persist-credentials: false
3937
ref: ${{ inputs.ref || github.sha }}
4038

4139
- uses: astral-sh/setup-uv@20cfd1bf945f4377ade1205e4dbc17946fc9a30d # v10.0.1
@@ -52,7 +50,7 @@ jobs:
5250
fi
5351
echo "version=$version" >> "$GITHUB_OUTPUT"
5452
55-
- name: Publish versioned documentation
53+
- name: Build versioned documentation
5654
env:
5755
VERSION: ${{ steps.docs.outputs.version }}
5856
run: |
@@ -66,8 +64,16 @@ jobs:
6664
uv run --group docs mike deploy --update-aliases --alias-type redirect "$VERSION" latest
6765
uv run --group docs mike set-default latest
6866
fi
67+
68+
- name: Push versioned documentation
69+
env:
70+
GH_TOKEN: ${{ github.token }}
71+
run: |
72+
gh auth setup-git
6973
git push origin gh-pages
7074
75+
- name: Prepare Pages artifact
76+
run: |
7177
git worktree add published gh-pages
7278
# Keep existing unversioned URLs serving the latest release, or dev
7379
# before the first release is published.

0 commit comments

Comments
 (0)