build_develop.yml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # Separate to the main build workflow for access to develop
  2. # environment secrets, largely similar to build.yaml.
  3. name: Build and Deploy develop
  4. on:
  5. push:
  6. branches: [develop]
  7. repository_dispatch:
  8. types: [element-web-notify]
  9. concurrency:
  10. group: ${{ github.repository_owner }}-${{ github.workflow }}-${{ github.ref_name }}
  11. cancel-in-progress: true
  12. jobs:
  13. build:
  14. name: "Build & Deploy develop.element.io"
  15. # Only respect triggers from our develop branch, ignore that of forks
  16. if: github.repository == 'vector-im/element-web'
  17. runs-on: ubuntu-latest
  18. environment: develop
  19. env:
  20. R2_BUCKET: "element-web-develop"
  21. R2_URL: ${{ secrets.CF_R2_S3_API }}
  22. R2_PUBLIC_URL: "https://element-web-develop.element.io"
  23. steps:
  24. - uses: actions/checkout@v3
  25. - uses: actions/setup-node@v3
  26. with:
  27. cache: "yarn"
  28. - name: Install Dependencies
  29. run: "./scripts/layered.sh"
  30. - name: Build, Package & Upload sourcemaps
  31. run: "./scripts/ci_package.sh"
  32. env:
  33. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  34. SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
  35. SENTRY_URL: ${{ secrets.SENTRY_URL }}
  36. SENTRY_ORG: element
  37. SENTRY_PROJECT: riot-web
  38. # We only deploy the latest bundles to Cloudflare Pages and use _redirects to fallback to R2 for
  39. # older ones. This redirect means that 'self' is insufficient in the CSP,
  40. # and we have to add the R2 URL.
  41. # Once Cloudflare redirects support proxying mode we will be able to ditch this.
  42. # See Proxying in support table at https://developers.cloudflare.com/pages/platform/redirects
  43. CSP_EXTRA_SOURCE: ${{ env.R2_PUBLIC_URL }}
  44. - run: mv dist/element-*.tar.gz dist/develop.tar.gz
  45. - uses: actions/upload-artifact@v3
  46. with:
  47. name: webapp
  48. path: dist/develop.tar.gz
  49. retention-days: 1
  50. - name: Extract webapp
  51. run: |
  52. mkdir _deploy
  53. tar xf dist/develop.tar.gz -C _deploy --strip-components=1
  54. - name: Copy config
  55. run: cp element.io/develop/config.json _deploy/config.json
  56. - name: Populate 404.html
  57. run: echo "404 Not Found" > _deploy/404.html
  58. - name: Populate _headers
  59. run: cp .github/cfp_headers _deploy/_headers
  60. # Redirect requests for the develop tarball and the historical bundles to R2
  61. - name: Populate _redirects
  62. run: |
  63. {
  64. echo "/develop.tar.gz $R2_PUBLIC_URL/develop.tar.gz 301"
  65. for bundle in $(aws s3 ls s3://$R2_BUCKET/bundles/ --endpoint-url $R2_URL --region=auto | awk '{print $2}'); do
  66. echo "/bundles/${bundle}* $R2_PUBLIC_URL/bundles/${bundle}:splat 301"
  67. done
  68. } | tee _deploy/_redirects
  69. env:
  70. AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
  71. AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
  72. - name: Wait for other steps to succeed
  73. uses: lewagon/[email protected]
  74. with:
  75. ref: ${{ github.ref }}
  76. running-workflow-name: "Build & Deploy develop.element.io"
  77. repo-token: ${{ secrets.GITHUB_TOKEN }}
  78. wait-interval: 10
  79. check-regexp: ^((?!SonarCloud|SonarQube|issues|board).)*$
  80. # We keep the latest develop.tar.gz on R2 instead of relying on the github artifact uploaded earlier
  81. # as the expires after 24h and requires auth to download.
  82. # Element Desktop's fetch script uses this tarball to fetch latest develop to build Nightlies.
  83. - name: Deploy to R2
  84. run: |
  85. aws s3 cp dist/develop.tar.gz s3://$R2_BUCKET/develop.tar.gz --endpoint-url $R2_URL --region=auto
  86. aws s3 cp _deploy/bundles s3://$R2_BUCKET/bundles --recursive --endpoint-url $R2_URL --region=auto
  87. env:
  88. AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
  89. AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
  90. - name: Deploy to Cloudflare Pages
  91. id: cfp
  92. uses: cloudflare/pages-action@1
  93. with:
  94. apiToken: ${{ secrets.CF_PAGES_TOKEN }}
  95. accountId: ${{ secrets.CF_PAGES_ACCOUNT_ID }}
  96. projectName: element-web-develop
  97. directory: _deploy
  98. gitHubToken: ${{ secrets.GITHUB_TOKEN }}
  99. - run: |
  100. echo "Deployed to ${{ steps.cfp.outputs.url }}" >> $GITHUB_STEP_SUMMARY