mirror of
https://github.com/discourse/discourse.git
synced 2026-08-02 09:29:37 -05:00
DEV: Publish and enable use of pre-built JS assets (#33973)
Building the Discourse ember app is resource-intensive process. This commit introduces a framework for us to build these assets centrally, and make them available for people to download. On every commit to `main`, a new GitHub actions workflow will build development & production versions of the core assets, and publish them as a github release under the `discourse/discourse-assets` repository. A separate repository is being used to avoid polluting the main `discourse/discourse` repository with one-git-tag-per-release. The `assemble_ember_build.rb` script is updated to fetch the relevant asset bundle. Requests are made to `get.discourse.org`, which then redirects to GitHub releases. This redirection service is being used so that we have the option to switch away from GitHub releases in future without breaking existing Discourse installations. For now, this behavior can be enabled by setting `DISCOURSE_DOWNLOAD_PRE_BUILT_ASSETS=1`. In the near future, we hope to make this the default, with opt-out via `DISCOURSE_DOWNLOAD_PRE_BUILT_ASSETS=0`.
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
name: Publish Assets
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- stable
|
||||
|
||||
concurrency:
|
||||
group: publish-assets-${{ format('{0}-{1}', github.ref, github.job) }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
publish-assets:
|
||||
if: github.repository == 'discourse/discourse'
|
||||
runs-on: 'debian-12-8core'
|
||||
container: discourse/discourse_test:release
|
||||
timeout-minutes: 30
|
||||
|
||||
steps:
|
||||
- name: Install gh cli
|
||||
run: |
|
||||
# https://github.com/cli/cli/blob/trunk/docs/install_linux.md#debian-ubuntu-linux-raspberry-pi-os-apt
|
||||
(type -p wget >/dev/null || (sudo apt update && sudo apt install wget -y)) \
|
||||
&& sudo mkdir -p -m 755 /etc/apt/keyrings \
|
||||
&& out=$(mktemp) && wget -nv -O$out https://cli.github.com/packages/githubcli-archive-keyring.gpg \
|
||||
&& cat $out | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg > /dev/null \
|
||||
&& sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg \
|
||||
&& sudo mkdir -p -m 755 /etc/apt/sources.list.d \
|
||||
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
|
||||
&& sudo apt update \
|
||||
&& sudo apt install gh -y
|
||||
- name: Set working directory owner
|
||||
run: chown root:root .
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Setup Git
|
||||
run: |
|
||||
git config --global user.email "ci@ci.invalid"
|
||||
git config --global user.name "Discourse CI"
|
||||
|
||||
- name: pnpm install
|
||||
run: pnpm install --frozen-lockfile
|
||||
|
||||
- name: build and release assets
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.DISCOURSE_ASSETS_RELEASE_TOKEN }}
|
||||
run: |
|
||||
script/publish_built_assets.rb
|
||||
Reference in New Issue
Block a user