Skip to content

Commit 7c8edd2

Browse files
Cleanup working dir when building the site
1 parent 8396569 commit 7c8edd2

1 file changed

Lines changed: 28 additions & 34 deletions

File tree

.github/workflows/publish-prod.yml

Lines changed: 28 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,64 @@
1-
# Build and publish documentation
2-
31
name: publish-prod
42

5-
# Controls when the workflow will run
63
on:
74
push:
85
branches:
96
- master
107
workflow_dispatch:
11-
branches:
12-
- master
138

149
jobs:
1510

1611
build:
1712
runs-on: self-hosted
1813
env:
1914
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
2318

2419
steps:
2520
- uses: actions/checkout@v2
2621

2722
- name: Submodule update
2823
run: |
24+
rm -rf ${{ env.WORK_DIR }}
2925
git submodule update --init --recursive
3026
git submodule foreach git pull origin master
3127
32-
- name: Install Hugo
28+
- name: Install tools
3329
run: |
3430
curl -LO https://github.com/gohugoio/hugo/releases/download/v0.101.0/hugo_extended_0.101.0_Linux-64bit.deb
3531
sudo dpkg -i hugo_extended_0.101.0_Linux-64bit.deb
36-
37-
- name: Install xmlstarlet
38-
run: |
3932
sudo apt install xmlstarlet
4033
4134
- name: Run and build Hugo
4235
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
4842
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
5245
5346
- name: Deploy sitemap
54-
uses: nogsantos/scp-deploy@master
47+
uses: burnett01/rsync-deployments@7.0.1
5548
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+
6256
- name: Deploy documentation
63-
uses: nogsantos/scp-deploy@master
57+
uses: burnett01/rsync-deployments@7.0.1
6458
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

Comments
 (0)