Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

deploy-gh-pages.sh 2.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
  1. #!/bin/bash
  2. #
  3. # Push HTML pages to the gh-pages branch of the current GitHub repository.
  4. #
  5. # Keeps pages built from branches in separate folders (named after the branch name).
  6. # Pages for the master branch are in the 'dev' folder. 'latest' is a link to
  7. # the 6.x branch.
  8. # To return a failure if any commands inside fail
  9. set -e
  10. set -x
  11. REPO=$BUILD_REPOSITORY_NAME
  12. BRANCH=gh-pages
  13. CLONE_DIR=deploy
  14. CLONE_ARGS="--quiet --branch=$BRANCH --single-branch"
  15. REPO_URL=https://${GITHUB_TOKEN}@github.com/${REPO}.git
  16. HTML_SRC=${BUILD_SOURCESDIRECTORY}/${HTML_BUILDDIR:-doc/_build/html}
  17. # Place the HTML in different folders for different branches
  18. # Only deploy master and 6.x branches
  19. if [[ "${BUILD_SOURCEBRANCHNAME}" =~ ^6\.[0-9]+$ ]]; then
  20. VERSION=${BUILD_SOURCEBRANCHNAME}
  21. elif [[ "${BUILD_SOURCEBRANCHNAME}" == "master" ]]; then
  22. VERSION=dev
  23. else
  24. echo -e "Not in master or 6.x branches. Deployment skipped."
  25. exit 0
  26. fi
  27. echo -e "DEPLOYING HTML TO GITHUB PAGES:"
  28. echo -e "Target: branch ${BRANCH} of ${REPO}"
  29. echo -e "HTML source: ${HTML_SRC}"
  30. echo -e "HTML destination: ${VERSION}"
  31. # Clone the project, using the secret token.
  32. # Uses /dev/null to avoid leaking decrypted key.
  33. echo -e "Cloning ${REPO}"
  34. git clone ${CLONE_ARGS} ${REPO_URL} ${CLONE_DIR} 2>&1 >/dev/null
  35. cd ${CLONE_DIR}
  36. # Configure git to a dummy Travis user
  37. git config user.email "AzurePipelines@nothing.com"
  38. git config user.name "AzurePipelines"
  39. # Delete all the files and replace with our new set
  40. echo -e "Remove old files from previous builds"
  41. rm -rf ${VERSION}
  42. cp -Rf ${HTML_SRC}/ ${VERSION}/
  43. # Need to have this file so that Github doesn't try to run Jekyll
  44. touch .nojekyll
  45. # Always link /latest to the 6.x branch docs
  46. if [[ "${VERSION}" != "dev" ]]; then
  47. echo -e "Setup link from ${VERSION} to 'latest'"
  48. rm -f latest
  49. ln -sf ${VERSION} latest
  50. fi
  51. echo -e "Add and commit changes"
  52. git add -A .
  53. git status
  54. # Always overwrite old commits
  55. git commit --amend --reset-author --no-edit
  56. echo -e "Pushing..."
  57. git push -fq origin $BRANCH 2>&1 >/dev/null
  58. echo -e "Finished uploading generated files."
  59. # Turn off exit on failure.
  60. set +x
  61. set +e
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...