-
-
Notifications
You must be signed in to change notification settings - Fork 172
112 lines (93 loc) · 3.94 KB
/
publish-docs.yml
File metadata and controls
112 lines (93 loc) · 3.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
name: Publish Docs
on:
push:
branches:
- master
# filter on version branches:
# circleci filtered on version branches like this:
# filters:
# branches:
# only:
# - master
# - /v[0-9]+\.[0-9]+/
# full regex filtering not supported: https://github.community/t/using-regex-for-filtering/16427
# subset filtering supported: https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#filter-pattern-cheat-sheet
- v[0-9]+.[0-9]+
paths:
- "docs/**"
- ".github/workflows/publish-docs.yml"
- "Makefile"
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: extract subdirectory
env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
run: |
export BRANCH_OR_TAG_NAME=${GITHUB_REF##*/}
# set up subdirectory path
# `/latest` if default branch
# branch name otherwise
if [ "${BRANCH_OR_TAG_NAME}" == "${DEFAULT_BRANCH}" ]; then
export PUBLISH_SUBDIRECTORY="latest"
else
# remove the preceeding "v"
export PUBLISH_SUBDIRECTORY=$(echo "${BRANCH_OR_TAG_NAME}" | sed 's/^v\(.*\)$/\1/')
fi
# debug output
echo "DEFAULT_BRANCH: ${DEFAULT_BRANCH}"
echo "BRANCH_OR_TAG_NAME: $BRANCH_OR_TAG_NAME"
echo "PUBLISH_SUBDIRECTORY: $PUBLISH_SUBDIRECTORY"
# set for next github action step
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
echo "PUBLISH_SUBDIRECTORY=$PUBLISH_SUBDIRECTORY" >> $GITHUB_ENV
- name: Determine if latest GA version
run: |
export BRANCH_OR_TAG_NAME=${GITHUB_REF##*/}
export IS_LATEST_GA_VERSION="0"
GA_VER=$(curl -sSL https://stackstorm.com/packages/install.sh|grep ^BRANCH=|sed 's/[^0-9.]*//g')
if [ "${BRANCH_OR_TAG_NAME}" = "v${GA_VER}" ]; then
echo "Current GA Version. Deploy root"
IS_LATEST_GA_VERSION="1"
else
echo "Not current GA version"
fi
# debug output
echo "BRANCH_OR_TAG_NAME: $BRANCH_OR_TAG_NAME"
echo "IS_LATEST_GA_VERSION: $IS_LATEST_GA_VERSION"
# set for next github action step
# https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#environment-files
echo "IS_LATEST_GA_VERSION=$IS_LATEST_GA_VERSION" >> $GITHUB_ENV
- name: Build
env:
python_version: python3.8
run: |
make st2
sudo apt-get update
# python3-dev is already available
# sudo apt install python3-dev
sudo apt install libldap2-dev
sudo apt install libsasl2-dev
sudo pip3 install virtualenv
make docs
# turn off jekyll so that url routing works properly with underscores
touch docs/build/html/.nojekyll
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: docs/build/html
destination_dir: ${{ env.PUBLISH_SUBDIRECTORY}}
# TODO: running a gh-pages publish while one is ongoing will result in the previous execution being cancelled in favor of the subsequent one
# We cannot use the following step without ensuring it won't cancel other active gh-pages deployments
# since deploying the root in gh pages will wipe away any other versioned subdirectories,
# deploy the latest ga version to a `ga` subdirectory, and use routing to point the root docs.stackstorm.com to `docs.stackstorm.com/ga`
# - name: Deploy to Root GitHub Pages
# uses: peaceiris/actions-gh-pages@v3
# if: ${{ env.IS_LATEST_GA_VERSION == '1' }}
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: docs/build/html
# destination_dir: "ga"