denoland / denoland/deploy_feedback
Deployment lifecycle: post-deploy scripts and other hooks
- Dominant language
- No language data
- Stars
- 79
- Forks
- 5
- PR merge metrics
- No merged PRs in 30d
Description
### What problem are you trying to solve?
Currently, if we want to run scripts after a deployment, we need to configure our CI pipeline to do so and make sure they are run only when needed. Or do it ourselves in our entrypoint, waiting for the task to end before starting our server and failing the deployment if something bad happens.
Which is ok of course, but it could be interesting to have it more integrated into the deno ecosystem and have a better control of the deployment lifecycle. A bit like the [Cron job](https://docs.deno.com/deploy/kv/manual/cron/) service.
The [Queue](https://docs.deno.com/deploy/kv/manual/queue_overview/) service could be used on boot of the server as well. But, it would require extra work to make sure it is handled only when needed ([for example](https://docs.deno.com/deploy/kv/manual/queue_overview/#queue-api-with-kv-atomic-transactions)).
**Use cases**
- Running a migration script
- Triggering a task/process only once after the first time it is deployed
- Triggering a task/process after each new deploy
- Running some healthchecks
- ...
### Describe the solution you'd like
For now, this is an example of the tooling we wrote to help us achieve something similar to a "post-deploy" task:
```ts
// file: entry.deno.ts
const kv = await Deno.openKv();
const cache = await caches.open("my-cache");
await DeployTask
.once("set default preferences - only once", async () => {
const preferences = { theme: "dark", currency: "USD" };
const entries = await kv.list({ prefix: ["users"] });
for await (const entry of entries) {
const user = entry.value;
const key = ["preferences", user.id];
await kv.atomic()
.check({ key, versionstamp: null })
.set(key, value)
.commit();
}
})
.each("clear the edge cache - after each deploy", { retryCount: 2 }, async () => {
await Promise.allSettled(cache.keys().map((key) => cache.delete(key)));
})
.run({ debug: true });
Deno.serve(() => { /* ... */ });
```
It does the job well. But like Cron jobs, it could be nice to have it integrated in our project dashboard to see results of tasks and more debugging information in case of failure.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.