···11+# sourcehut
22+33+The sourcehut provider submits jobs to a
44+[builds.sr.ht](https://man.sr.ht/builds.sr.ht/) instance. Each Tangled
55+workflow becomes one job: tack submits the job via GraphQL, polls it
66+until terminal, and publishes `sh.tangled.pipeline.status` records on
77+each transition.
88+99+## Configure tack
1010+1111+| Env var | Description |
1212+| ----------------------- | ------------------------------------------------------ |
1313+| `TACK_SOURCEHUT_TOKEN` | Personal access token for builds.sr.ht (enables provider) |
1414+| `TACK_SOURCEHUT_INSTANCE` | Base URL override (default `https://builds.sr.ht`) |
1515+1616+Generate a token at `https://meta.sr.ht/oauth2/personal-token` with
1717+`builds.sr.ht/JOBS:RW` access, set the `TACK_SOURCEHUT_TOKEN=$token` env var,
1818+then start tack.
1919+2020+## Workflow YAML
2121+2222+Your sourcehut build manifest is defined via tangled workflow inline - see `tack.sourcehut.manifest`.
2323+It is submitted to builds.sr.ht verbatim, with a few `TACK_*` environment
2424+variables merged into its top-level `environment:` map.
2525+2626+```yaml
2727+when:
2828+ - event: ["push"]
2929+ branch: ["main"]
3030+3131+engine: tack
3232+3333+tack:
3434+ sourcehut:
3535+ manifest: |
3636+ image: alpine/edge
3737+ sources:
3838+ - https://tangled.org/j3s.sh/testy
3939+ tasks:
4040+ - test: |
4141+ ls -l testy
4242+```
4343+4444+Optional fields:
4545+4646+```yaml
4747+tack:
4848+ sourcehut:
4949+ instance: https://selfhosted.sr.ht.example.org
5050+ tags: ["tack", "ci"]
5151+ note: "manual note for the job list"
5252+ secrets: true
5353+```
5454+5555+* `instance`: full URL (with scheme) of an alternate builds.sr.ht
5656+ deployment. Defaults to the provider's configured instance.
5757+* `tags`: passed through to the submit API. Defaults to `["tack"]` so
5858+ jobs are filterable in the builds.sr.ht UI.
5959+* `note`: passed through to the submit API. Defaults to
6060+ `tangled: <workflow> @ <short-commit>`.
6161+* `secrets`: opt in to sourcehut secret injection. Default `false`.
6262+6363+## Injected environment
6464+6565+Tack merges the following into the manifest's `environment:` map
6666+before submitting. These can be overridden via user definition.
6767+6868+| Variable | Value |
6969+| -------------------- | -------------------------------------- |
7070+| `TACK_KNOT` | Knot host the trigger came from |
7171+| `TACK_PIPELINE_RKEY` | Pipeline record rkey |
7272+| `TACK_WORKFLOW` | Workflow name |
7373+| `TACK_WORKFLOW_RAW` | Raw workflow YAML body |
7474+| `TACK_ACTOR` | Triggering DID |
7575+| `TACK_COMMIT` | Commit SHA |
7676+| `TACK_BRANCH` | Branch ref |
7777+7878+## Status mapping
7979+8080+| builds.sr.ht status | tack status |
8181+| --------------------- | ----------- |
8282+| `pending`, `queued` | `pending` |
8383+| `running` | `running` |
8484+| `success` | `success` |
8585+| `failed`, `timeout` | `failed` |
8686+| `cancelled` | `cancelled` |
8787+8888+Unknown upstream statuses are logged.