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.4 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
  1. #!/usr/bin/env 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 -x -e
  10. # Detect if this is a release or from the master branch
  11. if [[ "$GITHUB_EVENT_NAME" == "release" ]]; then
  12. # Get the tag name without the "refs/tags/" part
  13. version="${GITHUB_REF#refs/*/}"
  14. elif [[ "$GITHUB_EVENT_NAME" == "push" ]] && [[ "${GITHUB_REF#refs/*/}" =~ ^6\.[0-9]+$ ]]; then
  15. version="${GITHUB_REF#refs/*/}"
  16. elif [[ "$GITHUB_EVENT_NAME" == "push" ]] && [[ "${GITHUB_REF#refs/*/}" == "master" ]]; then
  17. version=dev
  18. else
  19. echo -e "Not in master or 6.x branches. Deployment skipped."
  20. exit 0
  21. fi
  22. echo "Deploying version: $version"
  23. # Make the new commit message. Needs to happen before cd into deploy
  24. # to get the right commit hash.
  25. message="Deploy $version from $(git rev-parse --short HEAD)"
  26. cd deploy
  27. # Need to have this file so that Github doesn't try to run Jekyll
  28. touch .nojekyll
  29. # Delete all the files and replace with our new set
  30. echo -e "\nRemoving old files from previous builds of ${version}:"
  31. rm -rvf ${version}
  32. echo -e "\nCopying HTML files to ${version}:"
  33. cp -Rvf ../build/doc/rst/html/ ${version}/
  34. # If this is a new release, update the link from /latest to it
  35. if [[ "${version}" != "dev" ]]; then
  36. echo -e "\nSetup link from ${version} to 'latest'."
  37. rm -f latest
  38. ln -sf ${version} latest
  39. fi
  40. # Stage the commit
  41. git add -A .
  42. echo -e "\nChanges to be applied:"
  43. git status
  44. # Configure git to be the GitHub Actions account
  45. git config user.email "github-actions[bot]@users.noreply.github.com"
  46. git config user.name "github-actions[bot]"
  47. # If this is a dev build and the last commit was from a dev build
  48. # (detect if "dev" was in the previous commit message), reuse the
  49. # same commit
  50. if [[ "${version}" == "dev" && `git log -1 --format='%s'` == *"dev"* ]]; then
  51. echo -e "\nAmending last commit:"
  52. git commit --amend --reset-author -m "$message"
  53. else
  54. echo -e "\nMaking a new commit:"
  55. git commit -m "$message"
  56. fi
  57. # Make the push quiet just in case there is anything that could leak
  58. # sensitive information.
  59. echo -e "\nPushing changes to gh-pages."
  60. git push -fq origin gh-pages 2>&1 >/dev/null
  61. echo -e "\nFinished uploading generated files."
  62. # Turn off exit on failure.
  63. set +x +e
Tip!

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

Comments

Loading...