77 - develop
88 # For documentation specific to a release
99 - ' release-v*'
10+ # stable docs
11+ - master
1012
1113 workflow_dispatch :
1214
@@ -25,40 +27,35 @@ jobs:
2527 - name : Build the documentation
2628 run : mdbook build
2729
28- # Deploy to the latest documentation directories
29- - name : Deploy latest documentation
30- uses : peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
31- with :
32- github_token : ${{ secrets.GITHUB_TOKEN }}
33- keep_files : true
34- publish_dir : ./book
35- destination_dir : ./develop
36-
37- - name : Get the current Synapse version
30+ # Figure out the target directory.
31+ #
32+ # The target directory depends on the name of the branch
33+ #
34+ - name : Get the target directory name
3835 id : vars
39- # The $GITHUB_REF value for a branch looks like `refs/heads/release-v1.2`. We do some
40- # shell magic to remove the "refs/heads/release-v" bit from this, to end up with "1.2",
41- # our major/minor version number, and set this to a var called `branch-version`.
42- #
43- # We then use some python to get Synapse's full version string, which may look
44- # like "1.2.3rc4". We set this to a var called `synapse-version`. We use this
45- # to determine if this release is still an RC, and if so block deployment.
4636 run : |
47- echo ::set-output name=branch-version::${GITHUB_REF#refs/heads/release-v}
48- echo ::set-output name=synapse-version::`python3 -c 'import synapse; print(synapse.__version__)'`
49-
50- # Deploy to the version-specific directory
51- - name : Deploy release-specific documentation
52- # We only carry out this step if we're running on a release branch,
53- # and the current Synapse version does not have "rc" in the name.
54- #
55- # The result is that only full releases are deployed, but can be
56- # updated if the release branch gets retroactive fixes.
57- if : ${{ startsWith( github.ref, 'refs/heads/release-v' ) && !contains( steps.vars.outputs.synapse-version, 'rc') }}
58- uses : peaceiris/actions-gh-pages@v3
37+ # first strip the 'refs/heads/' prefix with some shell foo
38+ branch="${GITHUB_REF#refs/heads/}"
39+
40+ case $branch in
41+ release-*)
42+ # strip 'release-' from the name for release branches.
43+ branch="${branch#release-}"
44+ ;;
45+ master)
46+ # deploy to "latest" for the master branch.
47+ branch="latest"
48+ ;;
49+ esac
50+
51+ # finally, set the 'branch-version' var.
52+ echo "::set-output name=branch-version::$branch"
53+
54+ # Deploy to the target directory.
55+ - name : Deploy to gh pages
56+ uses : peaceiris/actions-gh-pages@068dc23d9710f1ba62e86896f84735d869951305 # v3.8.0
5957 with :
6058 github_token : ${{ secrets.GITHUB_TOKEN }}
6159 keep_files : true
6260 publish_dir : ./book
63- # The resulting documentation will end up in a directory named `vX.Y`.
64- destination_dir : ./v${{ steps.vars.outputs.branch-version }}
61+ destination_dir : ./${{ steps.vars.outputs.branch-version }}
0 commit comments