File tree 2 files changed +63
-0
lines changed
2 files changed +63
-0
lines changed Original file line number Diff line number Diff line change 98
98
working-directory : ./mdbook-spec
99
99
run : cargo fmt --check
100
100
101
+ preview :
102
+ runs-on : ubuntu-latest
103
+ steps :
104
+ - uses : actions/checkout@master
105
+ - name : Update rustup
106
+ run : rustup self update
107
+ - name : Install Rust
108
+ run : |
109
+ rustup set profile minimal
110
+ rustup toolchain install nightly
111
+ rustup default nightly
112
+ - name : Install mdbook
113
+ run : |
114
+ mkdir bin
115
+ curl -sSL https://github.com/rust-lang/mdBook/releases/download/v${MDBOOK_VERSION}/mdbook-v${MDBOOK_VERSION}-x86_64-unknown-linux-gnu.tar.gz | tar -xz --directory=bin
116
+ echo "$(pwd)/bin" >> $GITHUB_PATH
117
+ - name : Build the book
118
+ env :
119
+ SPEC_RELATIVE : 0
120
+ run : mdbook build
121
+ - name : Upload artifact
122
+ if : github.event_name == 'pull_request'
123
+ uses : actions/upload-artifact@v4
124
+ with :
125
+ name : preview-${{ github.event.pull_request.number }}
126
+ overwrite : true
127
+ path : book/**
128
+
101
129
# The success job is here to consolidate the total success/failure state of
102
130
# all other jobs. This job is then included in the GitHub branch protection
103
131
# rule which prevents merges unless all other jobs are passing. This makes
@@ -110,6 +138,7 @@ jobs:
110
138
- code-tests
111
139
- style-tests
112
140
- mdbook-spec
141
+ # preview is explicitly excluded here
113
142
runs-on : ubuntu-latest
114
143
steps :
115
144
- run : jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
Original file line number Diff line number Diff line change
1
+ name : Publish Preview
2
+ on :
3
+ workflow_dispatch :
4
+ inputs :
5
+ pr_num :
6
+ description : " PR number"
7
+ type : number
8
+ required : true
9
+
10
+ permissions :
11
+ contents : read
12
+
13
+ jobs :
14
+ publish :
15
+ name : Publish preview to GitHub Pages
16
+ runs-on : ubuntu-latest
17
+ permissions :
18
+ contents : write
19
+ steps :
20
+ - uses : actions/checkout@master
21
+ with :
22
+ ref : gh-pages
23
+ - name : Update GitHub Pages
24
+ env :
25
+ GH_TOKEN : ${{ github.token }}
26
+ run : |
27
+ git config user.name "Preview Deploy"
28
+ git config user.email ""
29
+ rm -rf pr-${{ inputs.pr_num }}
30
+ mkdir pr-${{ inputs.pr_num }}
31
+ gh run download --name preview-${{ inputs.pr_num }} --dir pr-${{ inputs.pr_num }}
32
+ git add -A
33
+ git commit --allow-empty -m 'Preview pr-${{ inputs.pr_num }}'
34
+ git push origin +gh-pages
You can’t perform that action at this time.
0 commit comments