cloudbuild-storybook.yaml 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. steps:
  2. - id: npm_ci
  3. name: "node:22.18.0"
  4. entrypoint: /bin/bash
  5. args:
  6. - '-c'
  7. - 'bin/npm_install_subset . libraries/* services/web'
  8. - id: build-storybook
  9. name: 'node:22.18.0'
  10. env:
  11. - 'BRANCH_NAME=$BRANCH_NAME'
  12. - 'BUILD_ID=$BUILD_ID'
  13. script: |
  14. #!/bin/bash
  15. set -e
  16. make -C services/web BRANCH_NAME="${BRANCH_NAME:-$BUILD_ID}" build_storybook
  17. - id: deploy-storybook
  18. name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  19. env:
  20. - 'BRANCH_NAME=$BRANCH_NAME'
  21. - 'BUILD_ID=$BUILD_ID'
  22. - 'BUCKET=gs://overleaf-dev-storybook'
  23. dir: services/web
  24. script: |
  25. #!/bin/bash
  26. : ${BRANCH_NAME:=$BUILD_ID}
  27. [[ "$BRANCH_NAME" ]] || {
  28. echo 1>&2 "ERROR: BRANCH_NAME not set"
  29. exit 2
  30. }
  31. gsutil -m copy -r storybook-output/* "${BUCKET}/"
  32. waitFor:
  33. - build-storybook
  34. - id: read-storybook-bucket
  35. name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  36. dir: services/web
  37. env:
  38. - 'BUCKET=gs://overleaf-dev-storybook'
  39. script: |
  40. #!/bin/bash
  41. set -ex
  42. gsutil ls "${BUCKET}/" \
  43. | sed -E "s@^${BUCKET}/([^/]+)/@\1@" \
  44. > storybook-bucket-listing.txt
  45. waitFor:
  46. - deploy-storybook
  47. - id: create-storybook-index
  48. name: 'node:22.18.0'
  49. dir: services/web
  50. env:
  51. - 'BRANCH_NAME=$BRANCH_NAME'
  52. script: |
  53. #!/bin/bash
  54. set -ex
  55. LIST=$(tr '\n' , < storybook-bucket-listing.txt)
  56. m4 -DLIST="$LIST" -DBRANCH_NAME="$BRANCH_NAME" cloudbuild-storybook-index.html.m4 > storybook-index.html
  57. waitFor:
  58. - read-storybook-bucket
  59. - id: update-storybook-index
  60. name: 'gcr.io/google.com/cloudsdktool/cloud-sdk'
  61. dir: services/web
  62. entrypoint: 'gsutil'
  63. args: [ "copy", "storybook-index.html", "gs://overleaf-dev-storybook/index.html" ]
  64. waitFor:
  65. - create-storybook-index