preview-docs.sh 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env bash
  2. # Copyright Materialize, Inc. and contributors. All rights reserved.
  3. #
  4. # Use of this software is governed by the Business Source License
  5. # included in the LICENSE file at the root of this repository.
  6. #
  7. # As of the Change Date specified in that file, in accordance with
  8. # the Business Source License, use of this software will be governed
  9. # by the Apache License, Version 2.0.
  10. set -euo pipefail
  11. . misc/shlib/shlib.bash
  12. if [[ "$BUILDKITE_PULL_REQUEST" = false ]]; then
  13. echo "Skipping docs preview on non-pull request build"
  14. exit 0
  15. fi
  16. cd doc/user
  17. hugo --gc --baseURL "/materialize/$BUILDKITE_PULL_REQUEST"
  18. cat > config.deployment.toml <<EOF
  19. [[deployment.targets]]
  20. name = "preview"
  21. url = "s3://materialize-website-previews?region=us-east-1&prefix=materialize/$BUILDKITE_PULL_REQUEST/"
  22. EOF
  23. hugo deploy --config config.toml,config.deployment.toml --force
  24. curl -fsSL \
  25. -H "Authorization: Bearer $GITHUB_TOKEN" \
  26. -H "Accept: application/vnd.github.v3+json" \
  27. "https://api.github.com/repos/MaterializeInc/materialize/statuses/$BUILDKITE_COMMIT" \
  28. --data "{\
  29. \"state\": \"success\",\
  30. \"description\": \"Deploy preview ready.\",\
  31. \"target_url\": \"https://preview.materialize.com/materialize/$BUILDKITE_PULL_REQUEST/\",\
  32. \"context\": \"preview-docs\"\
  33. }"