|
1 | | -# Build and publish documentation |
2 | | - |
3 | 1 | name: publish-prod |
4 | 2 |
|
5 | | -# Controls when the workflow will run |
6 | 3 | on: |
7 | 4 | push: |
8 | 5 | branches: |
9 | 6 | - master |
10 | 7 | workflow_dispatch: |
11 | | - branches: |
12 | | - - master |
13 | 8 |
|
14 | 9 | jobs: |
15 | 10 |
|
16 | 11 | build: |
17 | 12 | runs-on: self-hosted |
18 | 13 | env: |
19 | 14 | PRODUCT: viewer |
20 | | - ROOT_DIR: docs-cloud-common |
21 | | - SRC_DIR: docs-cloud-common/public |
22 | | - DEST_DIR: /var/www/docs.groupdocs.cloud/html |
| 15 | + WORK_DIR: docs-cloud-common |
| 16 | + PUBLIC_DIR: docs-cloud-common/public |
| 17 | + REMOTE_DIR: /var/www/docs.groupdocs.cloud/html |
23 | 18 |
|
24 | 19 | steps: |
25 | 20 | - uses: actions/checkout@v2 |
26 | 21 |
|
27 | 22 | - name: Submodule update |
28 | 23 | run: | |
| 24 | + rm -rf ${{ env.WORK_DIR }} |
29 | 25 | git submodule update --init --recursive |
30 | 26 | git submodule foreach git pull origin master |
31 | 27 |
|
32 | | - - name: Install Hugo |
| 28 | + - name: Install tools |
33 | 29 | run: | |
34 | 30 | curl -LO https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_extended_0.101.0_Linux-64bit.deb |
35 | 31 | sudo dpkg -i hugo_extended_0.101.0_Linux-64bit.deb |
36 | | - |
37 | | - - name: Install xmlstarlet |
38 | | - run: | |
39 | 32 | sudo apt install xmlstarlet |
40 | 33 |
|
41 | 34 | - name: Run and build Hugo |
42 | 35 | run: | |
43 | | - # echo ${{ env.ROOT_DIR }} |
44 | | - cp -r content/* ${{ env.ROOT_DIR }}/content/ |
45 | | - hugo --source ${{ env.ROOT_DIR }} --minify --config config-geekdoc.toml |
46 | | - rootUrl=$(sed -n -e '/^baseURL/p' ${{ env.ROOT_DIR }}/config-geekdoc.toml | sed 's/baseURL//; s/\s*//g; s/=//; s/"//g') |
47 | | - # echo $rootUrl |
| 36 | + # Copy content |
| 37 | + cp -r content/* ${{ env.WORK_DIR }}/content/ |
| 38 | + hugo --source ${{ env.WORK_DIR }} --minify --config config-geekdoc.toml |
| 39 | + # Read root URL from the config file |
| 40 | + rootUrl=$(sed -n -e '/^baseURL/p' ${{ env.WORK_DIR }}/config-geekdoc.toml | sed 's/baseURL//; s/\s*//g; s/=//; s/"//g') |
| 41 | + # Create pattern to search for `storage` or `total` pages |
48 | 42 | pattern="//*[*[contains(text(),'${rootUrl}storage') or contains(text(),'${rootUrl}total')]]" |
49 | | - # echo $pattern |
50 | | - xmlstarlet ed --inplace -d "$pattern" ${{ env.SRC_DIR }}/product-sitemap.xml |
51 | | - # less ${{ env.SRC_DIR }}/product-sitemap.xml |
| 43 | + # Remove entries with `storage` and `total` substring |
| 44 | + xmlstarlet ed --inplace -d "$pattern" ${{ env.PUBLIC_DIR }}/product-sitemap.xml |
52 | 45 |
|
53 | 46 | - name: Deploy sitemap |
54 | | - uses: nogsantos/scp-deploy@master |
| 47 | + uses: burnett01/rsync-deployments@7.0.1 |
55 | 48 | with: |
56 | | - src: ${{ env.SRC_DIR }}/product-sitemap.xml |
57 | | - host: ${{ secrets.DOCS_SSH_HOST }} |
58 | | - remote: ${{ env.DEST_DIR }}/sitemaps/${{ env.PRODUCT }}.xml |
59 | | - user: ${{ secrets.DOCS_SSH_USER }} |
60 | | - key: ${{ secrets.DOCS_SSH_KEY }} |
61 | | - |
| 49 | + switches: |
| 50 | + path: ${{ env.PUBLIC_DIR }}/product-sitemap.xml |
| 51 | + remote_path: ${{ env.REMOTE_DIR }}/sitemaps/${{ env.PRODUCT }}.xml |
| 52 | + remote_host: ${{ secrets.DOCS_SSH_HOST }} |
| 53 | + remote_user: ${{ secrets.DOCS_SSH_USER }} |
| 54 | + remote_key: ${{ secrets.DOCS_SSH_KEY }} |
| 55 | + |
62 | 56 | - name: Deploy documentation |
63 | | - uses: nogsantos/scp-deploy@master |
| 57 | + uses: burnett01/rsync-deployments@7.0.1 |
64 | 58 | with: |
65 | | - src: ${{ env.SRC_DIR }}/${{ env.PRODUCT }} |
66 | | - host: ${{ secrets.DOCS_SSH_HOST }} |
67 | | - remote: ${{ env.DEST_DIR }} |
68 | | - user: ${{ secrets.DOCS_SSH_USER }} |
69 | | - key: ${{ secrets.DOCS_SSH_KEY }} |
70 | | - |
| 59 | + switches: -vzr --delete |
| 60 | + path: ${{ env.PUBLIC_DIR }}/${{ env.PRODUCT }} |
| 61 | + remote_path: ${{ env.REMOTE_DIR }} |
| 62 | + remote_host: ${{ secrets.DOCS_SSH_HOST }} |
| 63 | + remote_user: ${{ secrets.DOCS_SSH_USER }} |
| 64 | + remote_key: ${{ secrets.DOCS_SSH_KEY }} |
0 commit comments