diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ef58d4ea0..25518f40c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -139,6 +139,12 @@ jobs: name: build-output path: dist/backoffice/browser + # Vercel reads vercel.json from the pushed commit. Build branches + # hold only the built files, so add one that turns off deployments. + - name: Turn off Vercel deployments for the build branch + run: | + echo '{ "git": { "deploymentEnabled": false } }' > dist/backoffice/browser/vercel.json + - name: Deploy the application uses: MrYuion/git-publish-subdir-action@develop env: @@ -171,6 +177,12 @@ jobs: name: build-output path: dist/backoffice/browser + # Vercel reads vercel.json from the pushed commit. Build branches + # hold only the built files, so add one that turns off deployments. + - name: Turn off Vercel deployments for the build branch + run: | + echo '{ "git": { "deploymentEnabled": false } }' > dist/backoffice/browser/vercel.json + - name: Deploy the application uses: MrYuion/git-publish-subdir-action@develop env: diff --git a/.github/workflows/demo-site.yml b/.github/workflows/demo-site.yml new file mode 100644 index 000000000..1e0ae5179 --- /dev/null +++ b/.github/workflows/demo-site.yml @@ -0,0 +1,39 @@ +# Updates backoffice.demo.place.tech once per day. +# Vercel deploys only the backoffice-demo branch (see vercel.json). This workflow +# moves that branch to develop when develop changed since the last run. +name: 'Demo Site' + +on: + schedule: + - cron: '0 17 * * *' # daily at 17:00 UTC (3–4 am Sydney) + workflow_dispatch: # manual run: updates now if develop changed + +permissions: + contents: write + +concurrency: + group: demo-site + cancel-in-progress: false + +jobs: + update_demo_site: + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - uses: actions/checkout@v6 + with: + ref: develop + + - name: Move backoffice-demo to develop + shell: bash + run: | + develop="$(git rev-parse HEAD)" + current="$(git ls-remote origin refs/heads/backoffice-demo | cut -f1)" + if [[ "${current}" == "${develop}" ]]; then + echo "backoffice-demo is already at develop (${develop})." + exit 0 + fi + # The lease makes the push fail if backoffice-demo moved after the check. + git push --force-with-lease="refs/heads/backoffice-demo:${current}" \ + origin "HEAD:refs/heads/backoffice-demo" + echo "Moved backoffice-demo from ${current:-nothing} to ${develop}." diff --git a/README.md b/README.md index 287e3531b..c46bf9088 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,15 @@ uses hash-based routing and enables its service worker only in production. Backoffice sends errors to Sentry. See [`docs/sentry.md`](docs/sentry.md) to set the DSN for a domain and to set up source map uploads. +## Demo site + +The `backoffice` Vercel project serves [backoffice.demo.place.tech](https://backoffice.demo.place.tech/). Vercel deploys only the `backoffice-demo` branch. The Vercel team can create a limited number of deployments each day, and Vercel counts failed and canceled deployments too. Thus, other branches must not create Vercel deployments: + +- `vercel.json` turns off Vercel deployments for all branches except `backoffice-demo`. +- The `BUILD` workflow adds a `vercel.json` that turns off Vercel deployments to each `build/*` branch commit. Vercel reads `vercel.json` from the pushed commit, and build branches do not contain the root file. + +The `Demo Site` workflow moves `backoffice-demo` to `develop` once per day (17:00 UTC), if `develop` changed. To update the site now, run the workflow manually. Do not push to `backoffice-demo` directly. + ## Stack - Angular 22 and Angular Material diff --git a/vercel.json b/vercel.json new file mode 100644 index 000000000..b53651844 --- /dev/null +++ b/vercel.json @@ -0,0 +1,9 @@ +{ + "$schema": "https://openapi.vercel.sh/vercel.json", + "git": { + "deploymentEnabled": { + "**": false, + "backoffice-demo": true + } + } +}