Docs menu

GitHub as a sourceDepends on how Ivy is set upFor administrators

A collection can mirror the issues of GitHub repositories, and the items of one GitHub project, as records. In practice that’s the built-in tasks collection, so every board over it shows the issues as cards. GitHub stays the source of truth: changes on GitHub appear in Ivy, and edits made in Ivy go to GitHub first.

The source depends on the installation: it needs collections and connections for flows, which your Ivy operator turns on. It is declared in the collection file, and a space admin applies it. Linking people and managing the webhook secret also need a space admin, and Ivy asks them to confirm their identity first. For using boards themselves, see Tasks and boards.

What you need

A GitHub App connection of the space, declared in connections.ivy.yaml with its private key set (see GitHub App connections). On GitHub, give the app these permissions, and declare the same ones:

Permission Needed for
Issues: read and write Reading issues and sending Ivy’s edits back
Metadata: read Every app has it
Organization projects: read and write Only to mirror a project
ivy: connections/v1
connections:
  github:
    hosts: [api.github.com, github.com]
    auth:
      github_app:
        app_id: 123456
        installation_id: 7890123
        repositories: [support, website]
        permissions:
          issues: write
          metadata: read
          organization_projects: write

Install the app on the repositories you want to mirror. Several sources, in one collection or in several, can use the same connection.

Declare the source

A source is an entry of sources in the collection file. For tasks, it goes into the extension file, the file with extends: tasks (see the collection file reference); any other collection declares it in its own file.

ivy: collection/v1
extends: tasks
sources:
  - id: github
    provider: github
    connection: github
    repositories: [support, website]
    project: { owner: acme, number: 3, field: Status }
    map:
      title: title
      body: detail
      state: { field: status, open: todo, closed: done }
      project_status: { field: status, values: { "In progress": doing } }
      assignees: assignees
      labels: labels
    max_items: 1000
Key What it says
id The source’s name, unique in the file: lowercase letters, digits and _, starting with a letter, at most 40 characters. Flows see it in trigger.by.
provider github, the only provider.
connection A GitHub App connection of the space’s connections.ivy.yaml.
repositories 1 to 20 of the repositories the connection declares, as name or owner/name. A bare name is looked up in the app’s installation.
project Optional: a GitHub project by its owner and number, and field, its single-select status field, matched by name regardless of case (Status when left out).
map Which field of the collection each part of an issue goes into (below).
max_items How many issues the source mirrors at most: 1,000 when left out, at most 50,000.

A collection file has at most four sources. The file’s check makes sure the fields in map exist and have the right type, that no field is mapped from two keys (field_mapped_twice; state and project_status may share one), and that every required field without a default is mapped (required_unmapped). The connection lives in another file, so Ivy checks it when the source is applied.

Map fields onto the collection

map names a field of the collection for each part of an issue. The mapping goes both ways: GitHub’s values fill the fields, and Ivy’s edits of these fields go back to GitHub.

Key Part of the issue Field of the collection
title The title A text field
body The body A text or markdown field
state Open or closed An options field (enum): open and closed name its option keys
project_status The option of the project’s field An options field: values maps each option’s name on GitHub to an option key; needs project
assignees The assignees A list of people
labels The labels A list of text

In the example, an open issue is todo, a closed one done, and an item whose project status is “In progress” is doing. Back the other way, setting a task’s status to done closes its issue, todo reopens it, and doing sets the project’s status to “In progress”. Fields the map doesn’t name, such as due, stay in Ivy.

Each key of map is optional. An open issue takes the open option unless the project gives it a status; a project status that values doesn’t list takes the field’s first option. values lists at most 50 statuses.

Apply the source

Adding, changing or removing a source waits for a space admin, like a change that widens access. A new collection file applies at once without its sources, and the version with them waits; a file with extends: tasks that declares sources waits too. Until a space admin applies the waiting version, after confirming their identity, the collection keeps the version applied last, with its sources as they were.

Applying checks that the connection is a GitHub App connection with its value set (otherwise connection_missing or not_github_app), that it declares issues: write, and organization_projects: write for a project (permission_missing), and that each repository is among those it declares (repository_not_declared). Then Ivy starts the first sync: it reads the repositories’ issues, and the project’s items, and creates a record for each. A bare repository name the app’s installation doesn’t have stops the sync with repository_missing.

Ivy remembers the connection’s declaration as it was when the source was applied. If the declaration in connections.ivy.yaml changes, for example to more repositories or permissions, the source pauses until a space admin confirms the source again; Ivy asks them to confirm their identity first.

Link GitHub logins to people of the space. An issue assigned to a linked login shows that person as the assignee, and assigning that person in Ivy assigns the login on GitHub. Only linked logins show as people. Unlinked logins stay on the issue: Ivy keeps them and sends them back with every change of the assignees, and people without a link can’t be assigned to a mirrored record. Only a space admin links people, with Link people on the collection’s source and after confirming their identity, because a link decides whose name an assignment shows.

Set up the webhook

Without a webhook, Ivy catches up with GitHub every 15 minutes; with one, changes arrive within seconds. The webhook belongs to the space’s connection, so one set-up serves every source that uses it.

  1. A space admin creates a webhook secret for the connection, after confirming their identity. Ivy shows the webhook’s address, https://<your Ivy address>/api/v1/webhooks/github/{webhook_id}, and the secret. The secret is shown only once.
  2. On GitHub, open the app’s settings, turn on Webhook, and paste the address as the webhook URL and the secret as the webhook secret.
  3. Under the app’s events, subscribe to Issues and, for a project, Projects v2 item.

Ivy checks every delivery’s signature with the secret and ignores repeated deliveries. A delivery only tells Ivy which issue changed: Ivy then reads the issue from GitHub itself and never trusts the delivery’s content.

Rotate or revoke the secret

To rotate the secret, create a new one, paste it into the app’s settings on GitHub, then revoke the old one in Ivy. Both are accepted in the meantime, so no delivery is lost. Revoking the only secret stops deliveries until you create a new one.

What is mirrored

Each issue of the repositories (not pull requests), and each project item that is one of their issues, becomes a record with the fields of map, and a link to the issue. Comments written on GitHub aren’t mirrored into Ivy. An issue that is deleted, transferred or leaves the chosen repositories leaves the collection.

What Ivy sends back

Change in Ivy On GitHub
The field of state Closes or reopens the issue
The field of project_status Sets the project’s status field
The fields of title and body The issue’s title and body
The field of assignees The issue’s assignees: linked people’s logins, and the unlinked logins it already had
The field of labels The issue’s labels
A comment An issue comment ending “— via Ivy by” and the author’s name
Other fields, card order Nothing: they stay in Ivy

Ivy refuses to delete a mirrored record (mirrored_record); close the issue on GitHub, or remove the source.

GitHub first, then Ivy

An edit of a mirrored record’s mapped fields shows at once in Ivy, marked as pending until GitHub confirms it. A comment goes to GitHub first in the same way, and links to the issue comment once GitHub has it. If GitHub refuses the write for good, for example because the issue was deleted or is locked, the record goes back to its earlier values and shows the error.

If GitHub refuses the connection itself, because the app lacks a permission, its installation was removed or the connection’s value needs setting or confirming again, nothing is lost: edits and comments wait, the source warns “GitHub refuses access” with the reason, and a waiting comment says “Waiting for GitHub access”. Once a space admin fixes the app or the connection, Ivy checks again and sends what waited.

If someone changed the same field on GitHub after Ivy last read it, GitHub’s newer value wins: your edit is dropped and the record panel says “Changed on GitHub meanwhile; GitHub’s value was kept.” Edits of other fields still go through.

Flows on mirrored records

A record trigger counts the source’s changes like anyone else’s (see Flows). For a change that came from GitHub, trigger.by is {type: source, id: github}, with the source’s id, so a flow can tell GitHub’s changes from people’s. The first sync creates a record for each issue, and each starts a run of a created trigger on the collection; a trigger that starts more than 60 runs in an hour pauses its flow.

Limits and catching up

  • Size: a source mirrors at most max_items issues, 1,000 unless the file says otherwise. Past that it stops adding records, keeps the ones it has and says so; narrow its repositories, close old issues or raise max_items.
  • Catching up: every 15 minutes Ivy compares the collection with GitHub, so a missed delivery is picked up. A space editor can ask for this at once with Sync now on the collection’s source, which also shows when it last synced and any problem.
  • Rate limits: Ivy keeps within GitHub’s rate limits and retries later rather than fail.
  • Privacy: mirrored issues are space content. Only the space’s members see them.

Remove the source

To stop mirroring, remove the source from sources in the collection file. Like adding it, the change waits for a space admin, who confirms their identity before applying it. Applying it deletes the records the source mirrored from the collection; nothing changes on GitHub.