[WIP] [docs] Deploy docs (#742)

Add a GitHub workflow to deploy docs. If this works, will start using
this same approach for the other web apps in our repo.
This commit is contained in:
Manav Rathi 2024-03-08 13:30:28 +05:30 committed by GitHub
commit 215e89427d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 120 additions and 5 deletions

46
.github/workflows/docs-deploy.yml vendored Normal file
View file

@ -0,0 +1,46 @@
name: "Deploy (docs)"
on:
# Run on every push to main that changes docs/
push:
branches: [main]
paths:
- "docs/**"
- ".github/workflows/docs-deploy.yml"
# Also allow manually running the action
workflow_dispatch:
jobs:
deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: docs
steps:
- name: Checkout code
uses: actions/checkout@v4
- 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 production site
# Will create docs/.vitepress/dist
run: yarn build
- name: Publish
uses: cloudflare/pages-action@1
with:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
projectName: ente
directory: docs/docs/.vitepress/dist
wranglerVersion: "3"

View file

@ -11,5 +11,4 @@ can use it to safely store your 2FA codes (second-factor authentication codes).
> [!CAUTION]
>
> These docs are still incomplete. If you feel like documenting an issue you ran
> into and then found a solution to, help us [fill them
> in](/about/contributing).
> into and then found a solution to, help us [fill them in](/about/contribute).

View file

@ -10,4 +10,4 @@ Ende-zu-Ende-verschlüsselte Authenticator-App für jedermann. Wir sind froh, da
du hier bist!
**Please note that this German translation is currently just a placeholder.**
Know German? [Help us fill this in!](/about/contributing).
Know German? [Help us fill this in!](/about/contribute).

View file

@ -15,5 +15,5 @@ If you are using VPN, please try disabling the VPN or switching provider.
The desktop/web app tries to detect if a particular file is video or image. If
the detection fails, then the app skips the upload. Please contact our
[support](support.ente.io) if you find that a valid file did not get detected
and uploaded.
[support](mailto:support@ente.io) if you find that a valid file did not get
detected and uploaded.

70
web/docs/deploy-new.md Normal file
View file

@ -0,0 +1,70 @@
# Deploying
The various web apps and static sites in this repository are deployed on
Cloudflare Pages. This document describes details of how things were setup, and
how deployments happen on changes.
The summary of what happens is:
* `docs/` get deployed to [help.ente.io](https://help.ente.io) whenever
something that changes `docs/` gets merged to main.
You likely don't need to know the rest of the details (until you do, but you can
read on then).
## First time preparation
Create a new Pages project in Cloudflare, setting it up to use [Direct
Upload](https://developers.cloudflare.com/pages/get-started/direct-upload/).
> [!NOTE]
>
> Direct upload doesn't work for existing projects tied to your repository using
> the [Git
> integration](https://developers.cloudflare.com/pages/get-started/git-integration/).
>
> If you want to keep the pages.dev domain from an existing project, you should
> be able to delete your existing project and recreate it (assuming no one
> claims the domain in the middle). I've not seen this documented anywhere, but
> it worked when I tried, and it seems to have worked for [other people
> too](https://community.cloudflare.com/t/linking-git-repo-to-existing-cf-pages-project/530888).
There are two ways to create a new project, using Wrangler
[[1](https://github.com/cloudflare/pages-action/issues/51)] or using the
Cloudflare dashboard
[[2](https://github.com/cloudflare/pages-action/issues/115)]. Since this is one
time thing, the second option might be easier.
The remaining steps are documented in [Cloudflare's guide for using Direct
Upload with
CI](https://developers.cloudflare.com/pages/how-to/use-direct-upload-with-continuous-integration/).
As a checklist,
- Generate `CLOUDFLARE_API_TOKEN`
- Add `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` to the GitHub secrets
- Add your workflow. e.g. see `docs-deploy.yml`.
This is the basic setup, and should already work.
## Deploying multiple sites
However, we wish to deploy multiple sites from this same repository, so the
standard Cloudflare conception of a single "production" branch doesn't work for
us.
Instead, we tie each deployment to a branch name. Note that we don't have to
actually create the branch or push to it, this branch name is just used as the
the `branch` parameter that gets passed to `cloudflare/pages-action`.
Since our root pages project is `ente.pages.dev`, so a branch named `foo` would
be available at `foo.ente.pages.dev`.
Finally, we create CNAME aliases using a [Custom Domain in
Cloudflare](https://developers.cloudflare.com/pages/how-to/custom-branch-aliases/)
to point to these deployments from our user facing DNS names.
As a concrete example, the GitHub workflow that deploys `docs/` passes "help" as
the branch name. The resulting deployment is available at "help.ente.pages.dev".
Finally, we add a custom domain to point to it from
[help.ente.io](https://help.ente.io).