2022-05-16 14:23:44 +00:00
|
|
|
# Separate to the main build workflow for access to develop
|
|
|
|
# environment secrets, largely similar to build.yaml.
|
2022-11-08 13:27:20 +00:00
|
|
|
name: Build and Deploy develop
|
2022-05-16 14:23:44 +00:00
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [develop]
|
|
|
|
repository_dispatch:
|
|
|
|
types: [element-web-notify]
|
2022-08-04 16:07:22 +00:00
|
|
|
concurrency:
|
2022-11-08 13:27:20 +00:00
|
|
|
group: ${{ github.repository_owner }}-${{ github.workflow }}-${{ github.ref_name }}
|
2022-08-04 16:07:22 +00:00
|
|
|
cancel-in-progress: true
|
2022-05-16 14:23:44 +00:00
|
|
|
jobs:
|
|
|
|
build:
|
2022-11-08 13:27:20 +00:00
|
|
|
name: "Build & Deploy develop.element.io"
|
2022-06-14 10:30:12 +00:00
|
|
|
# Only respect triggers from our develop branch, ignore that of forks
|
|
|
|
if: github.repository == 'vector-im/element-web'
|
2022-05-16 14:23:44 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
environment: develop
|
2022-11-08 13:27:20 +00:00
|
|
|
env:
|
|
|
|
R2_BUCKET: "element-web-develop"
|
|
|
|
R2_URL: ${{ secrets.CF_R2_S3_API }}
|
|
|
|
R2_PUBLIC_URL: "https://element-web-develop.element.io"
|
2022-05-16 14:23:44 +00:00
|
|
|
steps:
|
2022-11-29 18:44:51 +00:00
|
|
|
- uses: actions/checkout@v3
|
2022-05-16 14:23:44 +00:00
|
|
|
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
cache: "yarn"
|
|
|
|
|
|
|
|
- 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 11:08:17 +00:00
|
|
|
SENTRY_ORG: element
|
|
|
|
SENTRY_PROJECT: riot-web
|
2022-11-08 13:27:20 +00: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 10:50:47 +00:00
|
|
|
|
2022-09-05 08:40:37 +00:00
|
|
|
- run: mv dist/element-*.tar.gz dist/develop.tar.gz
|
|
|
|
|
|
|
|
- uses: actions/upload-artifact@v3
|
|
|
|
with:
|
|
|
|
name: webapp
|
|
|
|
path: dist/develop.tar.gz
|
|
|
|
retention-days: 1
|
2022-11-08 13:27:20 +00: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 08:40:37 +00:00
|
|
|
|
2022-08-02 11:38:05 +00:00
|
|
|
- name: Populate _headers
|
2022-07-13 08:57:51 +00:00
|
|
|
run: cp .github/cfp_headers _deploy/_headers
|
2022-11-08 13:27:20 +00:00
|
|
|
|
|
|
|
# Redirect requests for the develop tarball and the historical bundles to R2
|
|
|
|
- name: Populate _redirects
|
2022-12-09 12:28:29 +00:00
|
|
|
run: |
|
|
|
|
{
|
2022-11-08 13:27:20 +00:00
|
|
|
echo "/develop.tar.gz $R2_PUBLIC_URL/develop.tar.gz 301"
|
|
|
|
for bundle in $(aws s3 ls s3://$R2_BUCKET/bundles/ --endpoint-url $R2_URL --region=auto | awk '{print $2}'); do
|
|
|
|
echo "/bundles/${bundle}* $R2_PUBLIC_URL/bundles/${bundle}:splat 301"
|
2022-12-09 12:28:29 +00:00
|
|
|
done
|
2022-11-08 13:27:20 +00:00
|
|
|
} | tee _deploy/_redirects
|
2022-12-09 12:28:29 +00:00
|
|
|
env:
|
2022-11-08 13:27:20 +00:00
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
|
2022-12-09 12:28:29 +00:00
|
|
|
|
2022-11-08 13:27:20 +00:00
|
|
|
- name: Wait for other steps to succeed
|
|
|
|
uses: lewagon/wait-on-check-action@v1.2.0
|
2022-12-09 12:28:29 +00:00
|
|
|
with:
|
2022-07-13 08:57:51 +00:00
|
|
|
ref: ${{ github.ref }}
|
2022-11-08 13:27:20 +00:00
|
|
|
running-workflow-name: "Build & Deploy develop.element.io"
|
2022-07-13 08:57:51 +00:00
|
|
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
2022-11-08 13:27:20 +00:00
|
|
|
wait-interval: 10
|
|
|
|
check-regexp: ^((?!SonarCloud|SonarQube|issues|board).)*$
|
2022-12-09 12:28:29 +00:00
|
|
|
|
2022-11-08 13:27:20 +00: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 12:33:46 +00:00
|
|
|
aws s3 cp _deploy/ s3://$R2_BUCKET/ --recursive --endpoint-url $R2_URL --region=auto
|
2022-11-08 13:27:20 +00:00
|
|
|
env:
|
|
|
|
AWS_ACCESS_KEY_ID: ${{ secrets.CF_R2_ACCESS_KEY_ID }}
|
|
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.CF_R2_TOKEN }}
|
2022-12-09 12:28:29 +00:00
|
|
|
|
2022-11-08 13:27:20 +00:00
|
|
|
- name: Deploy to Cloudflare Pages
|
|
|
|
id: cfp
|
|
|
|
uses: cloudflare/pages-action@1
|
|
|
|
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 12:28:29 +00:00
|
|
|
|
2022-11-08 13:27:20 +00:00
|
|
|
- run: |
|
|
|
|
echo "Deployed to ${{ steps.cfp.outputs.url }}" >> $GITHUB_STEP_SUMMARY
|