# GitHub releases to X: n8n template with an approval table and preflight check

This n8n workflow queues each published GitHub release once, by release ID, in an n8n data table. After a person sets approved to true, it checks the post with PubNio's validate call and sends it to X only when the check passes, with up to three release-note paragraphs as a thread.

Download: <https://pubnio.com/templates/n8n/github-release-to-x.json> (n8n workflow JSON, no credentials inside). Checked on n8n 2.50.7. Destination: X (Live).

## What it does

- **Trigger.** A GitHub Trigger on release events queues items; a Schedule Trigger every 15 minutes posts approved ones.
- **Approval.** Set the release's approved column to true in the data table.
- **Request.** One validate request per approved first send, then one create only for rows that pass; a resend after a lost answer goes straight to the create. Each create carries the item's saved key as `Idempotency-Key`, and every request sends `PubNio-Version: 2026-12-02`.
- **Result.** The answer is written back to the item; the next runs read the post's status until every destination settles.

## Fields: Data table pubnio_releases

| Field | Type | Use |
| --- | --- | --- |
| `source_id` | string | `release-<id>`, the stable row ID. |
| `text` | string | `<repo> <tag> is out: <name>` and the release URL; edit it before approving. |
| `detail` | string | Up to three release-note paragraphs, each a reply in the thread. |
| `approved` | boolean | true posts the release. |

The workflow also fills `pubnio_key`, `pubnio_post_id`, `pubnio_status`, `pubnio_outcome`, `pubnio_error`, `pubnio_sent_at`; create them as text fields.

## Set up

1. **Create a PubNio API key.** In PubNio, create an API key with the publish scope; it includes read, which the status checks use.
2. **Import the workflow.** Download the JSON and import it into n8n with Import from File. It is checked on n8n 2.50.7.
3. **Add the PubNio credential.** Create a Header Auth credential named PubNio API key with name Authorization and value Bearer followed by the key. Select it on **Check post with PubNio**, **Create post in PubNio**, **Read post status**.
4. **Fill PubNio settings.** Open the PubNio settings node and set `workspaceId`, `xAccountId`. `xAccountId`: The X account ID from PubNio's list of connected accounts.
5. **Create the pubnio_releases data table.** In n8n, create a data table named pubnio_releases with the fields above plus the pubnio_ text fields. On **GitHub release**, select your GitHub credential, the repository owner, and the repository; n8n registers the release webhook when you activate the workflow.
6. **Run one approved test item.** Approve one test item, run the workflow once, and read pubnio_status and pubnio_outcome. Then activate it.

## Request

The same body goes to PubNio's validate request first; only `canPublish: true` continues to the create.

```json
{
  "text": "acme/app v1.4.0 is out: Faster exports\nhttps://github.com/acme/app/releases/tag/v1.4.0",
  "targets": [
    {
      "accountId": "44444444-4444-4444-8444-444444444444",
      "settings": {
        "thread": [
          "Exports run faster.",
          "New CSV options.",
          "Fixes a crash on empty files."
        ]
      }
    }
  ]
}
```

## Tested behavior

The download is imported unchanged into a clean n8n 2.50.7 container, and its node types, versions, parameters, and operations are checked against that release. Then a copy runs with n8n execute. Its PubNio requests and its Code, If, Switch, and Merge nodes run as published. Its trigger and source nodes are simulated by a fake source with the same row shapes, its media wait is cut to one second, and PubNio is a fake API that decodes every request with PubNio's own schemas and checks it with PubNio's own content rules. PubNio's test suite replays every create and validate request the run sent against the real API and requires the same answer. It proves:

- Only approved items are sent to PubNio.
- The key is a hash of the stable row ID, saved on the row with its send time before the request that sends it.
- A lost response (503 after PubNio admitted the post) is resent with the same key and PubNio returns the first post.
- A key with no post ID that was sent 23 hours and 1 minute ago, or has no send time, stops at needs_review instead of being resent.
- A 202 is recorded as queued or scheduled, never as published, until a delivery reports it.
- A GitHub redelivery and a non-`published` release action queue nothing; each release is queued once, unapproved.
- Nothing reaches PubNio before approval. Each approved first send is validated; a release title over X's limit records `rejected` with `caption_too_long` and no key or post.
- A resend after a lost answer skips the check and replays its saved key.
- The passing release is sent once, with the first three release-note paragraphs as `settings.thread`.

## Recovery

- **When pubnio_status is `rejected` after the check:** Shorten text in the data table, clear pubnio_status, and the next run checks it again.
- **When pubnio_error names `insufficient_credit`:** X posts are metered in PubNio. Add credit to the workspace, clear pubnio_status, and the next run sends the release again.
- **When a release was edited on GitHub after it was queued:** Edit the row's text; the queue is not refreshed from GitHub.

## Limits

- Data tables are an n8n feature; this template needs an n8n version with them (it is checked on the pinned version).
- Releases only; pushes and tags are ignored.
- PubNio has no approval step of its own; approval happens in GitHub before n8n calls PubNio.
- The check uses a fake PubNio and fake provider answers, so this page shows no real delivery.

## Related

- [n8n integration: every PubNio template](https://pubnio.com/integrations/n8n)
- [PubNio quickstart](https://pubnio.com/docs/quickstart/)

