2022-05-16 17:23:44 +03:00
|
|
|
# Separate to the main build workflow for access to develop
|
|
|
|
# environment secrets, largely similar to build.yaml.
|
2022-11-08 16:27:20 +03:00
|
|
|
name: Build and Deploy develop
|
2022-05-16 17:23:44 +03:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [develop]
|
|
|
|
repository_dispatch:
|
|
|
|
types: [element-web-notify]
|
2022-08-04 19:07:22 +03:00
|
|
|
concurrency:
|
2022-11-08 16:27:20 +03:00
|
|
|
group: ${{ github.repository_owner }}-${{ github.workflow }}-${{ github.ref_name }}
|
2022-08-04 19:07:22 +03:00
|
|
|
cancel-in-progress: true
|
2022-05-16 17:23:44 +03:00
|
|
|
jobs:
|
|
|
|
build:
|
2022-11-08 16:27:20 +03:00
|
|
|
name: "Build & Deploy develop.element.io"
|
2022-06-14 13:30:12 +03:00
|
|
|
# Only respect triggers from our develop branch, ignore that of forks
|
2023-12-12 13:31:44 +03:00
|
|
|
if: github.repository == 'element-hq/element-web'
|
2022-05-16 17:23:44 +03:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment: develop
|
2022-11-08 16:27:20 +03:00
|
|
|
env:
|
|
|
|
R2_BUCKET: "element-web-develop"
|
2023-04-11 20:58:55 +03:00
|
|
|
R2_URL: ${{ vars.CF_R2_S3_API }}
|
2022-11-08 16:27:20 +03:00
|
|
|
R2_PUBLIC_URL: "https://element-web-develop.element.io"
|
2022-05-16 17:23:44 +03:00
|
|
|
steps:
|
2023-09-05 20:31:32 +03:00
|
|
|
- uses: actions/checkout@v4
|
2022-05-16 17:23:44 +03:00
|
|
|
|
2023-10-31 21:42:07 +03:00
|
|
|
- uses: actions/setup-node@v4
|
2022-05-16 17:23:44 +03:00
|
|
|
with:
|
|
|
|
cache: "yarn"
|
2024-07-04 16:26:58 +03:00
|
|
|
node-version: "lts/*"
|
2022-05-16 17:23:44 +03:00
|
|
|
|
|
|
|
- name: Install Dependencies
|
|
|
|
run: "./scripts/layered.sh"
|
|
|
|
|
|
|
|
- name: Build, Package & Upload sourcemaps
|
|
|
|
run: "./scripts/ci_package.sh"
|
|
|
|
env:
|
|
|
|
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
|
|
|
|
SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
|
|
|
|
SENTRY_URL: ${{ secrets.SENTRY_URL }}
|
2022-08-02 14:08:17 +03:00
|
|
|
SENTRY_ORG: element
|
|
|
|
SENTRY_PROJECT: riot-web
|
2022-11-08 16:27:20 +03:00
|
|
|
# We only deploy the latest bundles to Cloudflare Pages and use _redirects to fallback to R2 for
|
|
|
|
# older ones. This redirect means that 'self' is insufficient in the CSP,
|
|
|
|
# and we have to add the R2 URL.
|
|
|
|
# Once Cloudflare redirects support proxying mode we will be able to ditch this.
|
|
|
|
# See Proxying in support table at https://developers.cloudflare.com/pages/platform/redirects
|
|
|
|
CSP_EXTRA_SOURCE: ${{ env.R2_PUBLIC_URL }}
|
2022-07-12 13:50:47 +03:00
|
|
|
|
2022-09-05 11:40:37 +03:00
|
|
|
- run: mv dist/element-*.tar.gz dist/develop.tar.gz
|
|
|
|
|
2024-01-19 11:54:43 +03:00
|
|
|
- uses: actions/upload-artifact@v4
|
2022-09-05 11:40:37 +03:00
|
|
|
with:
|
|
|
|
name: webapp
|
|
|
|
path: dist/develop.tar.gz
|
|
|
|
retention-days: 1
|
2022-11-08 16:27:20 +03:00
|
|
|
|
|
|
|
- name: Extract webapp
|
|
|
|
run: |
|
|
|
|
mkdir _deploy
|
|
|
|
tar xf dist/develop.tar.gz -C _deploy --strip-components=1
|
|
|
|
|
|
|
|
- name: Copy config
|
|
|
|
run: cp element.io/develop/config.json _deploy/config.json
|
|
|
|
|
|
|
|
- name: Populate 404.html
|
|
|
|
run: echo "404 Not Found" > _deploy/404.html
|
2022-09-05 11:40:37 +03:00
|
|
|
|
2022-08-02 14:38:05 +03:00
|
|
|
- name: Populate _headers
|
2022-07-13 11:57:51 +03:00
|
|
|
run: cp .github/cfp_headers _deploy/_headers
|
2022-11-08 16:27:20 +03:00
|
|
|
|
|
|
|
# Redirect requests for the develop tarball and the historical bundles to R2
|
2023-05-09 10:51:02 +03:00
|
|
|
# We find the latest 100 bundle.css files and add their bundles to the redirects file
|
|
|
|
# S3 has no sane way to get the age of a directory as they don't really exist
|
2022-11-08 16:27:20 +03:00
|
|
|
- name: Populate _redirects
|
2022-12-09 15:28:29 +03:00
|
|
|
run: |
|
|
|
|
{
|
2023-05-09 10:51:02 +03:00
|
|
|
echo "/develop.tar.gz $R2_PUBLIC_URL/develop.tar.gz 301"
|
2023-05-31 18:54:34 +03:00
|
|
|
aws s3api --region auto --endpoint-url $R2_URL list-objects-v2 --bucket $R2_BUCKET \
|
|
|
|
--query "sort_by(Contents[?ends_with(Key, '/bundle.css')], &LastModified)[-100:].Key" \
|
|
|
|
--prefix "bundles/" | jq -r '.[]' | grep -oE '[^\"].*\/\s*' | while read -r path ; do
|
2023-05-09 10:51:02 +03:00
|
|
|
echo "/${path}* $R2_PUBLIC_URL/${path}:splat 301"
|
|
|
|
done
|
2022-11-08 16:27:20 +03:00
|
|
|
} | tee _deploy/_redirects
|
2022-12-09 15:28:29 +03:00
|
|
|
env:
|
2022-11-08 16:27:20 +03:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
|
2022-12-09 15:28:29 +03:00
|
|
|
|
2024-03-18 14:25:38 +03:00
|
|
|
# We may be trying to deploy the same webapp bundles again, we need to ensure that the live bundles
|
|
|
|
# are not present in the _redirects file and instead accessed directly from Cloudflare Pages.
|
|
|
|
- name: Trim _redirects
|
|
|
|
working-directory: _deploy
|
|
|
|
run: |
|
|
|
|
find bundles -type d -mindepth 1 -maxdepth 1 -exec sed -i "\:{}:d" _redirects \;
|
|
|
|
|
2022-11-08 16:27:20 +03:00
|
|
|
- name: Wait for other steps to succeed
|
2024-04-16 15:43:15 +03:00
|
|
|
uses: t3chguy/wait-on-check-action@18541021811b56544d90e0f073401c2b99e249d6 # fork
|
2022-12-09 15:28:29 +03:00
|
|
|
with:
|
2023-01-30 17:08:15 +03:00
|
|
|
ref: ${{ github.sha }}
|
2022-11-08 16:27:20 +03:00
|
|
|
running-workflow-name: "Build & Deploy develop.element.io"
|
2022-07-13 11:57:51 +03:00
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-11-08 16:27:20 +03:00
|
|
|
wait-interval: 10
|
2024-06-06 14:22:36 +03:00
|
|
|
check-regexp: ^((?!SonarCloud|SonarQube|issue|board|label|Release|prepare|GitHub Pages).)*$
|
2022-12-09 15:28:29 +03:00
|
|
|
|
2022-11-08 16:27:20 +03:00
|
|
|
# We keep the latest develop.tar.gz on R2 instead of relying on the github artifact uploaded earlier
|
|
|
|
# as the expires after 24h and requires auth to download.
|
|
|
|
# Element Desktop's fetch script uses this tarball to fetch latest develop to build Nightlies.
|
|
|
|
- name: Deploy to R2
|
|
|
|
run: |
|
|
|
|
aws s3 cp dist/develop.tar.gz s3://$R2_BUCKET/develop.tar.gz --endpoint-url $R2_URL --region=auto
|
2023-01-12 15:33:46 +03:00
|
|
|
aws s3 cp _deploy/ s3://$R2_BUCKET/ --recursive --endpoint-url $R2_URL --region=auto
|
2022-11-08 16:27:20 +03:00
|
|
|
env:
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
|
2022-12-09 15:28:29 +03:00
|
|
|
|
2022-11-08 16:27:20 +03:00
|
|
|
- name: Deploy to Cloudflare Pages
|
|
|
|
id: cfp
|
2023-06-01 20:21:45 +03:00
|
|
|
uses: cloudflare/pages-action@f0a1cd58cd66095dee69bfa18fa5efd1dde93bca # v1
|
2022-11-08 16:27:20 +03:00
|
|
|
with:
|
|
|
|
apiToken: ${{ secrets.CF_PAGES_TOKEN }}
|
|
|
|
accountId: ${{ secrets.CF_PAGES_ACCOUNT_ID }}
|
|
|
|
projectName: element-web-develop
|
|
|
|
directory: _deploy
|
|
|
|
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
|
2022-12-09 15:28:29 +03:00
|
|
|
|
2022-11-08 16:27:20 +03:00
|
|
|
- run: |
|
|
|
|
echo "Deployed to ${{ steps.cfp.outputs.url }}" >> $GITHUB_STEP_SUMMARY
|