ci: upload the client build as an artifact (groundwork for PR previews) #7
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
We want a preview of the client for every pull request. Forgejo (v16, and the docs for v17) has no
workflow_runevent (forgejo/forgejo#7722), so the usual GitHub pattern — build without privileges, deploy from a second workflow defined on the default branch — is not available. Deploying from a job on thekoto-demorunner would let any pull request's workflow run on the host, because pull requests can choose that label.The plan is to let the host fetch the previews instead: CI builds the client in its throwaway container as it already does, uploads
client/distas an artifact, and a timer on the host (outside this repository's workflows) downloads the artifacts of successful runs through the Actions artifacts API (/repos/{owner}/{repo}/actions/runs/{run_id}/artifacts,/actions/artifacts/{id}/zip) and serves them as static files.Two things are unverified on this instance:
upload-artifact@v4works with our runner (upstream v4 refuses to run outside github.com; Forgejo publishes a fork atcode.forgejo.org/forgejo/upload-artifact@v4).Plan
.forgejo/workflows/ci.yml, after the build, uploadclient/distas an artifact namedclient-distwithhttps://code.forgejo.org/forgejo/upload-artifact@v4.No change to what runs on the host; the preview server itself is a later step.
First result from #8 (run 185): blocked by the reverse proxy in front of Forgejo, not by Forgejo or the action.
https://code.forgejo.org/forgejo/upload-artifact@v4runs on our runner: it validated the name and path (12 files fromclient/dist) and started the upload.413 Request Entity Too Largefromnginx/1.30.4, i.e. the origin's nginx in front of Forgejo (Cloudflare would answer with its own page and allows 100 MB). nginx defaultsclient_max_body_sizeto 1 MB; the build includes a 7.8 MB wasm file, and the artifact client uploads in chunks of several MB.GET /actions/runs/185/artifactsanswers 200[]andGET /actions/artifacts/1/zipanswers 404 (not 401), which suggests anonymous reads are allowed on this public repository, but that needs a real artifact to confirm.Next step: raise
client_max_body_sizeon that nginx (at least for Forgejo's Actions artifact upload paths, e.g.64m), then re-run the CI of #8.With the proxy's body size raised, the re-run of run 185 (#8) passed. Both open points are confirmed:
client-dist(artifact 5, 2,610,426 bytes) holds the 12 files ofclient/dist:index.html,config.json,sw.js,manifest.webmanifest, the icons and the hashed assets, including the 7.8 MB wasm.GET /actions/artifactsandGET /actions/runs/{id}/artifactslist it, andGET /actions/artifacts/5/zipreturns200with the zip (application/octet-stream).Notes for the host-side fetcher:
prettyref(#8),commit_shaandevent_payload, andstatusissuccessonly when every step passed.updated_atchanges, the id does not), so the fetcher has to compareupdated_ator the commit, not just the id.expires_at).