diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..36500f7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,44 @@ +name: Deploy + +on: + push: + # Each branch deploys to the GitHub environment with the same name. + branches: [staging, production] + +permissions: + contents: read + +concurrency: + group: deploy-${{ github.ref_name }} + cancel-in-progress: false + +jobs: + deploy: + name: Install HappyView modules (${{ github.ref_name }}) + runs-on: ubuntu-latest + environment: ${{ github.ref_name }} + steps: + - name: Check out repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + persist-credentials: false + + - name: Set up pnpm + uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + + - name: Set up Node.js + uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 + with: + node-version-file: .nvmrc + cache: pnpm + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install API modules into HappyView + env: + HAPPYVIEW_BASE_URL: ${{ vars.HAPPYVIEW_BASE_URL }} + HAPPYVIEW_ADMIN_TOKEN: ${{ secrets.HAPPYVIEW_ADMIN_TOKEN }} + HYPERCERTS_HANDLE_RESOLVER_URL: ${{ vars.HYPERCERTS_HANDLE_RESOLVER_URL }} + # The repo is the source of truth: replace any differing installed assets. + run: pnpm --filter @hypercerts-org/happyview-modules install:api --override diff --git a/happyview-modules/README.md b/happyview-modules/README.md index 81de3da..16d3dd3 100644 --- a/happyview-modules/README.md +++ b/happyview-modules/README.md @@ -53,3 +53,13 @@ pnpm install:api ``` For bundles that register `app.certified.actor.getProfile`, handle lookups require `HYPERCERTS_HANDLE_RESOLVER_URL` to be an HTTPS origin without credentials, path, query, or fragment. Interactive installs prompt when it is absent; noninteractive installs must set it. The admin token needs `script-variables:read`, and `script-variables:create` if the installer must create the setting. Existing settings are retained; HappyView exposes only a masked preview, so the installer cannot verify the configured value. See [CONTRIBUTING.md](../CONTRIBUTING.md) for release-note requirements and installer safety details. + +## Deploys + +Pushing to the `staging` or `production` branch runs [`.github/workflows/deploy.yml`](../.github/workflows/deploy.yml), which installs this bundle into that environment's HappyView with `pnpm install:api --override`, so assets that differ from this repository are replaced (the repository is the source of truth). Each branch uses the GitHub environment of the same name (`staging` or `production`), and each environment must define its own values; never reuse the production token for staging: + +- variable `HAPPYVIEW_BASE_URL`: that environment's HappyView origin +- secret `HAPPYVIEW_ADMIN_TOKEN`: a scoped admin token for that HappyView, including `script-variables:read` +- variable `HYPERCERTS_HANDLE_RESOLVER_URL`: needed only if that HappyView does not already have this setting; the token then also needs `script-variables:create` + +Deploys to each environment run one at a time and are never cancelled midway; staging and production deploys do not block each other.