Skip to content

Commit bfb46c0

Browse files
committed
Modify github actions script for publishing documentation
- Automatically publishing users documentation on develop or main (dev/main folder) - Automatically publishing users documentation on tag push (but including only major version number: e.g. v0)
1 parent f9f01c6 commit bfb46c0

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

.github/workflows/publish-users-doc.yml

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ name: Publish Users Documentation
22

33
on:
44
workflow_dispatch:
5+
push:
6+
branches:
7+
- main
8+
- develop
9+
paths:
10+
- 'doc/**'
11+
- 'docqueries/**'
12+
- 'locale/**'
513

614

715
jobs:
@@ -28,6 +36,14 @@ jobs:
2836
echo "PGIS=3" >> $GITHUB_ENV
2937
echo "PROJECT_VERSION=${PROJECT_VERSION}" >> $GITHUB_ENV
3038
39+
- name: Extract branch name and commit hash
40+
run: |
41+
raw=$(git branch -r --contains ${{ github.ref }})
42+
branch=${raw##*/}
43+
echo "BRANCH=$branch" >> $GITHUB_ENV
44+
git_hash=$(git rev-parse --short "$GITHUB_SHA")
45+
echo "GIT_HASH=$git_hash" >> $GITHUB_ENV
46+
3147
- name: Add PostgreSQL APT repository
3248
run: |
3349
sudo apt-get install curl ca-certificates gnupg
@@ -77,17 +93,20 @@ jobs:
7793
7894
- name: Update Users Documentation
7995
run: |
96+
if [[ "${{ env.BRANCH }}" == "main" ]]; then
97+
FOLDER_NAME="main"
98+
elif [[ "${{ env.BRANCH }}" == "develop" ]]; then
99+
FOLDER_NAME="dev"
100+
fi
80101
git checkout origin/gh-pages
81102
git checkout -b gh-pages
82-
PROJECT_MAJOR_MINOR="v${PROJECT_VERSION%.*}"
83-
rm -rf ${PROJECT_MAJOR_MINOR}
84-
cp -r build/doc/html ${PROJECT_MAJOR_MINOR}
85-
rm -rf ${PROJECT_MAJOR_MINOR}/es
86-
git add ${PROJECT_MAJOR_MINOR}
87-
git diff-index --quiet HEAD || git commit -m "Update users documentation for ${PROJECT_VERSION}"
103+
rm -rf ${FOLDER_NAME}
104+
cp -r build/doc/html ${FOLDER_NAME}
105+
git add ${FOLDER_NAME}
106+
git diff-index --quiet HEAD || git commit -m "Update users documentation for ${PROJECT_VERSION} (${{ env.BRANCH }}): commit ${{ env.GIT_HASH }}"
88107
git fetch origin
89108
git rebase origin/gh-pages
90109
git push origin gh-pages
91110
92111
env:
93-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,11 @@ jobs:
9999
run: |
100100
git checkout origin/gh-pages
101101
git checkout -b gh-pages
102-
PROJECT_MAJOR_MINOR="v${PROJECT_VERSION%.*}"
103-
rm -rf ${PROJECT_MAJOR_MINOR}
104-
cp -r build/doc/html ${PROJECT_MAJOR_MINOR}
105-
rm -rf ${PROJECT_MAJOR_MINOR}/es
106-
git add ${PROJECT_MAJOR_MINOR}
107-
git diff-index --quiet HEAD || git commit -m "Update users documentation for ${PROJECT_VERSION}"
102+
PROJECT_MAJOR="v${PROJECT_VERSION%%.*}"
103+
rm -rf ${PROJECT_MAJOR}
104+
cp -r build/doc/html ${PROJECT_MAJOR}
105+
git add ${PROJECT_MAJOR}
106+
git diff-index --quiet HEAD || git commit -m "Update users documentation for ${PROJECT_VERSION} (tag ${TAG_NAME})"
108107
git fetch origin
109108
git rebase origin/gh-pages
110109
git push origin gh-pages
@@ -117,7 +116,7 @@ jobs:
117116
rm -rf doxy/main
118117
cp -r build/doxygen/html doxy/main
119118
git add doxy/main
120-
git diff-index --quiet HEAD || git commit -m "Update developers documentation for ${PROJECT_VERSION}"
119+
git diff-index --quiet HEAD || git commit -m "Update developers documentation for ${PROJECT_VERSION} (tag ${TAG_NAME})"
121120
git fetch origin
122121
git rebase origin/gh-pages
123122
git push origin gh-pages
@@ -166,4 +165,4 @@ jobs:
166165
${{ github.event.repository.name }}-${{ env.PROJECT_VERSION }}.tar.gz
167166
168167
env:
169-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)