From 4feea018791182577a352877380a4c6ee2d40112 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Mar 2024 09:52:34 +0530 Subject: [PATCH 1/4] [web] Support preview deployments --- .github/workflows/web-preview.yml | 52 +++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/web-preview.yml diff --git a/.github/workflows/web-preview.yml b/.github/workflows/web-preview.yml new file mode 100644 index 0000000000..4727576730 --- /dev/null +++ b/.github/workflows/web-preview.yml @@ -0,0 +1,52 @@ +name: "Preview (web)" + +on: + workflow_dispatch: + inputs: + app: + description: "App to build and deploy" + type: choice + required: true + default: "photos" + options: + - "accounts" + - "auth" + - "cast" + - "photos" + +jobs: + deploy: + runs-on: ubuntu-latest + + defaults: + run: + working-directory: web + + steps: + - name: Checkout code + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Setup node and enable yarn caching + uses: actions/setup-node@v4 + with: + node-version: 20 + cache: "yarn" + cache-dependency-path: "docs/yarn.lock" + + - name: Install dependencies + run: yarn install + + - name: Build accounts + run: yarn build:${{ inputs.app }} + + - name: Publish accounts + uses: cloudflare/pages-action@1 + with: + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + projectName: ente + branch: preview + directory: web/apps/${{ inputs.app }}/out + wranglerVersion: "3" From 6efe2cd5fd4659917d4ee82934a64f9be3e14cf5 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Mar 2024 09:53:49 +0530 Subject: [PATCH 2/4] Add a push trigger to register the workflow See https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo --- .github/workflows/web-preview.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/web-preview.yml b/.github/workflows/web-preview.yml index 4727576730..1ecc2e052b 100644 --- a/.github/workflows/web-preview.yml +++ b/.github/workflows/web-preview.yml @@ -1,6 +1,7 @@ name: "Preview (web)" on: + push: # <- temporarily added so that we can register the action workflow_dispatch: inputs: app: From 8c23090abda1ace2a1b3eb6c8444d2f9936f5b38 Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Mar 2024 09:56:07 +0530 Subject: [PATCH 3/4] Remove placeholders --- .github/workflows/web-preview.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/web-preview.yml b/.github/workflows/web-preview.yml index 1ecc2e052b..4e86d9a816 100644 --- a/.github/workflows/web-preview.yml +++ b/.github/workflows/web-preview.yml @@ -1,7 +1,6 @@ name: "Preview (web)" on: - push: # <- temporarily added so that we can register the action workflow_dispatch: inputs: app: @@ -39,10 +38,10 @@ jobs: - name: Install dependencies run: yarn install - - name: Build accounts + - name: Build ${{ inputs.app }} run: yarn build:${{ inputs.app }} - - name: Publish accounts + - name: Publish ${{ inputs.app }} to preview uses: cloudflare/pages-action@1 with: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} From a9557df240d8b9102897ac9cbf58f6301a87b30b Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Tue, 12 Mar 2024 10:08:27 +0530 Subject: [PATCH 4/4] Add preview deployment docs --- web/docs/deploy.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/web/docs/deploy.md b/web/docs/deploy.md index 8e479db97f..c17de8ffa3 100644 --- a/web/docs/deploy.md +++ b/web/docs/deploy.md @@ -9,7 +9,11 @@ Cloudflare Pages. anything inside `docs/` gets merged to `main`. * Every night, all the web apps get automatically deployed to a nightly preview - URLs using the current code in main. + URLs (`*.ente.sh`) using the current code in main. + +* A preview deployment can be made by triggering the "Preview (web)" workflow. + This allows us to deploy a build of any of the apps from an arbitrary branch + to [preview.ente.sh](https://preview.ente.sh). Use the various `yarn deploy:*` commands to help with production deployments. For example, `yarn deploy:photos` will open a PR to merge the current `main` @@ -21,6 +25,7 @@ and publish to [web.ente.io](https://web.ente.io). > the merge commit. ## Deployments + Here is a list of all the deployments, whether or not they are production deployments, and the action that triggers them: @@ -36,6 +41,7 @@ deployments, and the action that triggers them: | [auth.ente.sh](https://auth.ente.sh) | Preview | Nightly deploy of `main` | | [cast.ente.sh](https://cast.ente.sh) | Preview | Nightly deploy of `main` | | [photos.ente.sh](https://photos.ente.sh) | Preview | Nightly deploy of `main` | +| [preview.ente.sh](https://preview.ente.sh) | Preview | Manually triggered | ### Other subdomains @@ -49,6 +55,19 @@ Apart from this, there are also some other deployments: - `payments.ente.io` and `family.ente.io` are currently in a separate repositories (Enhancement: bring them in here). +### Preview deployments + +To trigger a preview deployment, manually trigger the "Preview (web)" workflow +from the Actions tab on GitHub. You'll need to select the app to build, and the +branch to use. This'll then build the specified app (e.g. "photos") from that +branch, and deploy it to [preview.ente.sh](https://preview.ente.sh). + +The workflow can also be triggered using GitHub's CLI, gh. e.g. + +```sh +gh workflow run web-preview -F app=cast --ref my-branch +``` + --- ## Details