Skip to content

Commit fdb513d

Browse files
committed
A much more elaborate way to determine target docs folder
1 parent 9888d4b commit fdb513d

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

.github/workflows/docs.yml

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,23 @@ jobs:
2929
if: ${{ success() }}
3030
run: |
3131
invoke docs
32-
BRANCH_OR_TAG=${GITHUB_REF##*/}
33-
echo "Detected branch/tag: $BRANCH_OR_TAG"
34-
if [ $BRANCH_OR_TAG = "master" ]; then
35-
BRANCH_OR_TAG="latest"
32+
33+
# Get branch/tag/latest name from git
34+
GITHUB_REF_REGEX="tags/([0-9a-zA-Z\.\-]+)|(pull/[0-9]+)|heads/(.+)"
35+
36+
if [[ $GITHUB_REF =~ $GITHUB_REF_REGEX ]]; then
37+
if [[ $BASH_REMATCH = pull* ]]; then
38+
BRANCH_OR_TAG=pull_${BASH_REMATCH##*/}
39+
else
40+
BRANCH_OR_TAG=${BASH_REMATCH##*/}
41+
fi;
42+
if [[ $BRANCH_OR_TAG = master ]]; then
43+
BRANCH_OR_TAG=latest
44+
fi;
3645
fi;
37-
mkdir -p deploy/compas_fab/$BRANCH_OR_TAG && mv -T dist/docs deploy/compas_fab/$BRANCH_OR_TAG/
46+
3847
echo "Docs will be deployed to https://gramaziokohler.github.io/compas_fab/$BRANCH_OR_TAG"
48+
mkdir -p deploy/compas_fab/$BRANCH_OR_TAG && mv -T dist/docs deploy/compas_fab/$BRANCH_OR_TAG/
3949
- name: Deploy docs
4050
if: success()
4151
uses: crazy-max/ghaction-github-pages@v2

0 commit comments

Comments
 (0)