1
+ name : Doc
2
+
3
+ # To save env-var dynamically: https://github.com/actions/starter-workflows/issues/68#issuecomment-792338408
4
+ # Persist env-var across steps: echo "var=value" >> $GITHUB_ENV
5
+
6
+ # Note: search-index.js is changing every single time, even if source is not changing. This file is around 2 MB.
7
+ # Since the doc repo is cloned prior to committing, this might cause increasingly long CI times.defaults:
8
+ # If necessary, archive the 'gh-pages' branch from time to time, or overwrite it altogether -- doc history might not be that important.
9
+
10
+
11
+ on :
12
+ push :
13
+ branches : [master]
14
+
15
+
16
+ env :
17
+ GDNATIVE_LIB_RS_PREFIX : |-
18
+ //! _**Note:** This documentation refers to the [latest GitHub version](https://github.com/godot-rust/godot-rust) and is subject to change._<br>
19
+ //! _For stable releases, visit [docs.rs/gdnative](https://docs.rs/gdnative)._
20
+ //! <br><br>
21
+ //!
22
+ GDNATIVE_DOC_REPO : git@github.com:godot-rust/doc.git
23
+ GDNATIVE_DOC_BRANCH : gh-pages
24
+
25
+
26
+ # In the very unlikely cases where two PRs are merged, and the first 'doc' job is still running when the 2nd 'full-ci' starts,
27
+ # make sure the first one is awaited. Even though docs are eventually overwritten, this ensures continuitiy in the doc repo history.
28
+ concurrency :
29
+ group : ' sync-doc'
30
+ cancel-in-progress : false
31
+
32
+
33
+ jobs :
34
+ sync-doc :
35
+ runs-on : ubuntu-latest
36
+ steps :
37
+ - name : " Checkout"
38
+ uses : actions/checkout@v2
39
+
40
+ - name : " Install Rust"
41
+ uses : ./.github/composite/rust
42
+ with :
43
+ rust : stable
44
+ components : rustfmt
45
+
46
+ - name : " Pre-process input"
47
+ run : |
48
+ mv ${GITHUB_WORKSPACE}/gdnative/src/lib.rs tmp_lib.rs
49
+ (echo "${GDNATIVE_LIB_RS_PREFIX}"; cat tmp_lib.rs) > ${GITHUB_WORKSPACE}/gdnative/src/lib.rs
50
+
51
+ - name : " Generate documentation"
52
+ uses : actions-rs/cargo@v1
53
+ with :
54
+ command : doc
55
+ args : -p gdnative --lib --no-deps --all-features
56
+
57
+ # For email address, see https://github.community/t/github-actions-bot-email-address/17204
58
+ # As search-index.js changes every time, even if source hasn't changed, this will not need 'git commit --allow-empty'
59
+ - name : " Prepare upload"
60
+ run : |
61
+ mkdir ~/.ssh
62
+ echo '${{ secrets.DOC_DEPLOY_SSH_KEY }}' > ~/.ssh/id_rsa
63
+ chmod 700 ~/.ssh/id_rsa
64
+ git config --global user.name "godot-rust/doc[bot]"
65
+ git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
66
+
67
+ mkdir doc && cd doc
68
+ git clone --single-branch --branch ${GDNATIVE_DOC_BRANCH} --no-checkout ${GDNATIVE_DOC_REPO} . \
69
+ || (git init -b ${GDNATIVE_DOC_BRANCH} && git remote add origin ${GDNATIVE_DOC_REPO})
70
+
71
+ mv ${GITHUB_WORKSPACE}/target/doc/* .
72
+ mv ${GITHUB_WORKSPACE}/.github/workflows/doc/* .
73
+
74
+ GDNATIVE_VERSION=$(grep -Po '^version = "\K[^"]*' ${GITHUB_WORKSPACE}/gdnative/Cargo.toml)
75
+ GDNATIVE_SHORT_SHA=$(git rev-parse --short "${GITHUB_SHA}")
76
+
77
+ find gdnative -name .html -o -type f -print0 | xargs -0 sed -i 's/'"${GDNATIVE_VERSION}"'/master/g'
78
+
79
+ git add --all
80
+ git commit -m "Sync doc from ${GDNATIVE_SHORT_SHA}
81
+
82
+ Revision in godot-rust: ${GITHUB_SHA}"
83
+
84
+ - name : " Upload"
85
+ working-directory : doc
86
+ run : git push origin ${GDNATIVE_DOC_BRANCH}
87
+
88
+ - name : " Cleanup"
89
+ run : shred -u ~/.ssh/id_rsa
90
+
91
+
92
+
93
+ # Possible alternative: dispatching a remote workflow
94
+
95
+ # - name: 'Dispatch remote workflow'
96
+ # run: >
97
+ # curl
98
+ # -X POST
99
+ # -H "Accept: application/vnd.github.v3+json"
100
+ # https://api.github.com/repos/godot-rust/doc/actions/workflows/triggered-remotely/dispatches
101
+ # -d '{"ref":"master"}'
102
+
103
+ # - name: Repository Dispatch
104
+ # uses: peter-evans/repository-dispatch@v1
105
+ # with:
106
+ # repository: godot-rust/doc
107
+ # token: ${{ secrets.REPO_ACCESS_TOKEN }}
108
+ # event-type: my-event
0 commit comments