daneden / Zeitgeist

👁 An iOS app for keeping an eye on your Vercel deployments

Home Page:http://zeitgeist.daneden.me

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add redeploy feature

daneden opened this issue · comments

Apparently, redeployments are possible by POSTing to the "new deployments" endpoint with the same metadata (git commit) as the original deployment.

This will be harder than I originally thought! Currently, when decoding deployment metadata, the fields are transformed quite severely to make them comparable, so Swift doesn’t know how to encode them back to normal. For example, this payload:

{
  "meta": {
    "githubCommitMessage": "Initial commit",
  }
}

is decoded into (roughly):

let commit = AnyCommit(
  provider: .github,
  message: "Initial commit",
  
)

I’ll probably have to build a custom encoder, so deprioritising this for the time being.

Did some digging into Vercel's “Redeploy” button on their web UI. It makes a POST request to /v13/now/deployments?forceNew=1&withCache=1 with a body signature like so:

{
  "name": "nextjs-data-fetching",
  "gitSource": {
    "ref": "main",
    "type": "github",
    "sha": "71e7e2cedd5d1aa80c3831ba8fb1c9988447a9f8",
    "repoId": 369762962
  },
  "target": "production"
}

This is fairly different from the type signature of a deployment fetched via GET v5/now/deployments.

(Paging @leo who first suggested this approach!)

I’ll probably have to build a custom encoder, so deprioritising this for the time being.

Actually managed to build a quick static encode function on AnyCommit: e65726f