DOCS › SELF-HOST › GITHUB PULL REQUESTS

GitHub pull requests

Each article becomes one pull request in your repo, opened when the draft is ready so your checks run before you approve. You choose who merges.

FINE-GRAINED TOKEN OR YOUR OWN GITHUB APP

When a site's blog lives in a Git repo, Morningdesk opens a pull request for each article when its draft is ready, so your own CI and preview deploys run before you approve. It only ever writes one file per article, inside the content folder you confirmed, on a morningdesk/<slug>-<id> branch (the slug plus the first six characters of the article's id). Nothing reaches your live site until you approve the draft in the desk, and then only the way you chose:

  • Open the pull request and let me merge it in GitHub (default). Approving marks the PR ready for review and sets a Morningdesk: approved commit status on the exact commit you reviewed. Morningdesk never calls GitHub's merge endpoint. When it sees your merge, the article moves to Published and the live check runs. If anyone pushes after you approve, the status goes back to pending and the desk asks you to review again.
  • Merge for me. Morningdesk merges (squash) at the commit you reviewed, and only when the checks on it have passed. If your branch rules need a merge in GitHub (required reviews, a merge queue, classic branch protection), it tells you to merge in GitHub and watches for the merge.

Changing this setting affects new approvals only; pull requests already approved keep the mode they were approved with.

If you merge the pull request in GitHub before approving it in the desk, that merge counts as your approval: the article moves to Published, flagged "Merged in GitHub before you approved here", and the live check runs. If the pull request is closed without merging, the article goes back to Draft ready; approving it again reopens the pull request (or opens a new one when its branch was deleted).

What the desk writes, and what it refuses

  • Only inside the content folder. Never the root of the repo, never a hidden folder or dot-file (.github/, .env), never a symbolic link. A pull request that changes anything else, adds a symlink, or changes 3,000 or more files (GitHub can't list more, so the desk can't check them) can't be approved or merged from the desk.
  • One file per article, never someone else's. Slugs are unique on the site: when a post with the same slug exists in the folder, or another article uses it, the desk adds -2, -3 and so on. It never overwrites a file it didn't create ("A post with this slug already exists").
  • Text, not code. Your CI and preview builds run the draft before you approve it, so the post body is made inert: raw HTML is escaped, MDX import/export lines and {expressions} become text, and Liquid, Nunjucks and Hugo template tags ({{ }}, {% %}, {# #}, {{< >}}) are escaped (inside code blocks they are split with an invisible zero-width space). If anything executable were still left, the desk would refuse to open the pull request.
  • No skipped checks. Commit messages, the pull request's title and body, and the merge commit's title never carry [skip ci], [ci skip], [no ci], [skip actions], [actions skip] or skip-checks: true, even when the draft's title does. When checks ran on the pull request before, a head with no checks counts as not passed.
  • Your approval is for Morningdesk's commit. If someone else pushes to the pull request, the desk shows "Someone pushed to this PR" and you approve with their commits only after acknowledging them. If you reject an approved article, the Morningdesk: approved status becomes a failure, "Morningdesk: withdrawn".

Permissions

Grant exactly these repository permissions, on the blog's repo only:

Permission Access Why
Contents Read and write Read recent posts, create the branch, write the post file, merge (Merge for me)
Pull requests Read and write Open the draft PR, mark it ready for review
Commit statuses Read and write Set and read Morningdesk: approved; read other statuses
Checks Read See your CI and preview results before merging
Metadata Read Required by GitHub; also lets the desk read branch rulesets

Not needed: Administration (the desk reads rulesets instead of classic branch protection and treats GitHub's refusal as "Merge it in GitHub") and Workflows (the desk never touches .github/).

Option A: a fine-grained personal access token

  1. GitHub › Settings › Developer settings › Fine-grained tokens › Generate new token.
  2. Resource owner: the account or org that owns the repo. Repository access: Only select repositories, pick the blog.
  3. Repository permissions: as in the table above. Set an expiry you're comfortable with.
  4. In the desk, choose Use a fine-grained token instead and paste it (github_pat_…).

The token is encrypted at rest with the desk's secret key and is never shown again: the desk shows its last four characters only. When it expires, Settings › Connections shows Needs attention; approved articles wait until you paste a new one.

Fine-grained tokens may not be able to list check runs. The desk then uses commit statuses and lets GitHub's own merge answer decide; in "let me merge" mode this makes no difference.

Option B: your own GitHub App

  1. GitHub › Settings › Developer settings › GitHub Apps › New GitHub App. Give it a name (for example "Morningdesk for example.com"), turn Webhook off, set the repository permissions from the table above, and allow installation on your account only.

  2. Generate a private key and save the .pem file on the server, readable only by the desk's user (chmod 600).

  3. Start the desk with:

    terminal
    MORNINGDESK_GITHUB_APP_ID=123456
    MORNINGDESK_GITHUB_APP_SLUG=morningdesk-for-example-com
    MORNINGDESK_GITHUB_APP_PRIVATE_KEY_FILE=/etc/morningdesk/github-app.pem
  4. In the desk, Install on GitHub and pick the blog's repo. The desk exchanges the App's key for short-lived installation tokens (kept in memory only).

A GitHub App can't approve its own pull request, which is why approval shows up as a commit status, not a review.

The URL of new posts

For the live check, the desk needs to know where a post appears on your site. It guesses from the folder (content/blog → https://example.com/blog/{slug}); change it in Settings › Destinations › Edit if your site uses another pattern.