| 1 | #!/usr/bin/env bash |
| 2 | |
| 3 | set -ex |
| 4 | |
| 5 | echo "About to publish $GITHUB_REF to gh-pages..." |
| 6 | rm -rf ../gh-pages |
| 7 | |
| 8 | npm install vuepress@1 |
| 9 | npm install @vuepress/shared-utils@1 |
| 10 | npm run docs:build |
| 11 | |
| 12 | git config --global user.name "$GIT_USER_NAME" |
| 13 | git config --global user.email "$GIT_USER_EMAIL" |
| 14 | git clone -b gh-pages --single-branch https://"${GH_TOKEN_PUBLIC}"@github.com/ajv-validator/ajv.git ../gh-pages |
| 15 | |
| 16 | rsync -a ./docs/.vuepress/dist/ ../gh-pages |
| 17 | |
| 18 | cd ../gh-pages |
| 19 | |
| 20 | if [[ $(git status --porcelain) ]]; then |
| 21 | echo "Changes detected. Updating gh-pages branch..." |
| 22 | git add -A |
| 23 | git commit -m "updated by ajv workflow https://github.com/ajv-validator/ajv/actions/runs/$GITHUB_RUN_ID" |
| 24 | git push --quiet origin gh-pages > /dev/null 2>&1 |
| 25 | fi |
| 26 | |
| 27 | echo "Done" |