Skip to content

Commit f7c9391

Browse files
authored
Merge pull request #782 from Licini/doc-fix
stop deploy PRs and only keep latest patch
2 parents ae1a931 + 1f288bf commit f7c9391

File tree

2 files changed

+25
-53
lines changed

2 files changed

+25
-53
lines changed

.github/workflows/cleanup.yml

Lines changed: 0 additions & 45 deletions
This file was deleted.

.github/workflows/docs.yml

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ jobs:
1414
build:
1515
name: build and deploy docs
1616
runs-on: ubuntu-latest
17+
outputs:
18+
commit_type: ${{ steps.docs.outputs.commit_type }}
19+
current_patch: ${{ steps.docs.outputs.current_patch }}
1720
env:
1821
GH_PAT: ${{secrets.GH_PAT}}
1922
steps:
@@ -31,7 +34,8 @@ jobs:
3134
run: |
3235
python -m pip install --no-cache-dir -r requirements-dev.txt
3336
- name: Generate docs
34-
if: ${{ success() }}
37+
if: success()
38+
id: docs
3539
run: |
3640
invoke docs
3741
# Get branch/tag/latest name from git
@@ -40,19 +44,23 @@ jobs:
4044
if [[ $BASH_REMATCH = pull* ]]; then
4145
echo This is a pull request
4246
FOLDER_NAME=pull_${BASH_REMATCH##*/}
47+
echo "::set-output name=commit_type::pull"
4348
elif [[ $BASH_REMATCH = tags/* ]]; then
4449
echo This is a version tag
4550
FOLDER_NAME=${BASH_REMATCH##*/v}
51+
echo "::set-output name=commit_type::tag"
52+
echo "::set-output name=current_patch::$FOLDER_NAME"
4653
else
4754
echo This is a commit to main branch
4855
FOLDER_NAME=latest
56+
echo "::set-output name=commit_type::main"
4957
fi;
5058
fi;
5159
echo "Docs will be deployed to https://compas.dev/compas/$FOLDER_NAME"
5260
mkdir -p deploy/$BRANCH_OR_TAG && mv -T dist/docs deploy/$FOLDER_NAME/
5361
5462
- name: Deploy docs
55-
if: success() && env.GH_PAT != ''
63+
if: success() && env.GH_PAT != '' && steps.docs.outputs.commit_type != 'pull'
5664
uses: crazy-max/ghaction-github-pages@v2
5765
with:
5866
target_branch: gh-pages
@@ -63,27 +71,36 @@ jobs:
6371

6472
docVersions:
6573
needs: build
74+
if: needs.build.outputs.commit_type == 'tag'
6675
name: update doc versions
6776
runs-on: ubuntu-latest
6877
env:
6978
GH_PAT: ${{secrets.GH_PAT}}
79+
CURRENT_PATCH: ${{needs.build.outputs.current_patch}}
7080
steps:
71-
7281
- uses: actions/checkout@v2
7382
with:
7483
ref: gh-pages
7584

7685
- name: update doc versions
7786
run: |
78-
>doc_versions.txt
87+
echo latest > doc_versions.txt
88+
CURRENT_MINOR=${CURRENT_PATCH%.*}
89+
echo current patch: $CURRENT_PATCH current minor: $CURRENT_MINOR
7990
for folder in $(ls -rd */ | tr -d '/')
8091
do
81-
if [[ $folder =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}$|^latest$ ]]
82-
then
83-
echo ${folder} >> doc_versions.txt
92+
if [[ $folder =~ ^[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then
93+
PATCH=$folder
94+
MINOR=${folder%.*}
95+
if [[ $PATCH != $CURRENT_PATCH && $MINOR = $CURRENT_MINOR ]]; then
96+
echo $PATCH will be deleted
97+
rm -Rf $PATCH
98+
else
99+
echo $PATCH >> doc_versions.txt
100+
fi
84101
fi
85102
done
86-
echo found available doc versions:
103+
echo updated doc versions:
87104
cat doc_versions.txt
88105
89106
- name: Deploy docs

0 commit comments

Comments
 (0)