Export some env variables when submitting a build

This allows to detect if the build was started from a patch and for
example, skip deployment.

Example:
  BUILD_SUBMITTER=hub.sr.ht
  BUILD_REASON=patchset
  PATCHSET_ID=19897
  PATCHSET_URL=https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/19897

Ticket: ~sircmpwn/hub.sr.ht#70
This commit is contained in:
Alexey Yerin 2021-01-30 19:41:01 +03:00 committed by Drew DeVault
parent c86e3280d7
commit d8bac6c67c
1 changed files with 8 additions and 0 deletions

View File

@ -83,6 +83,14 @@ git am -3 /tmp/{payload["id"]}.patch"""
})
manifest.tasks.insert(0, task)
if not manifest.env:
manifest.env = {}
manifest.env.setdefault("BUILD_SUBMITTER", "hub.sr.ht")
manifest.env.setdefault("BUILD_REASON", "patchset")
manifest.env.setdefault("PATCHSET_ID", payload["id"])
manifest.env.setdefault("PATCHSET_URL", f"{ml.url()}/patches/{payload['id']}")
# Add webhook trigger
root = get_origin("hub.sr.ht", external=True)
details = fernet.encrypt(json.dumps({