| 1 | # @ghost/importer |
| 2 | |
| 3 | Imports a GitHub repository into Ghost: its git history, releases, issues, pull requests and issue comments. It is optional; without it the API turns GitHub imports off. |
| 4 | |
| 5 | The API drives it. A user starts an import, the API creates the repository and a `repository_import` row, then hands the job to `POST /imports` here with the user's GitHub token and a short-lived Ghost API key. The importer: |
| 6 | |
| 7 | 1. fetches `refs/heads/*`, `refs/tags/*` and |
| 8 | 2. pushes them to Ghost over HTTP with the API key, through the same path as any user's push, |
| 9 | 3. reads releases, pull requests, issues and comments from the GitHub REST API and sends them to the API in batches, |
| 10 | 4. reports the outcome. |
| 11 | |
| 12 | Every callback to the API renews the attempt's lease, and a heartbeat runs every 30 seconds. If the importer stops calling back, or refuses a job because it is busy, the API retries the import with backoff, up to six attempts. Each attempt carries a token; once the API moves on to a new attempt it answers the old one with 409, and the importer stops. |
| 13 | |
| 14 | Imported issues, pull requests, comments and releases are authored by the `ghost-importer` account, with the original GitHub author credited in the text. |
| 15 | |
| 16 | Not imported: release assets, Git LFS objects, review comments on pull request lines, reactions, assignees and milestones. |
| 17 | |
| 18 | ## Configuration |
| 19 | |
| 20 | | Variable | Default | | |
| 21 | | --- | --- | |
| 22 | | `IMPORTER_SECRET` | | Shared with the API, which sends it with jobs and receives it with callbacks. At least 16 characters. |
| 23 | | `GHOST_API_URL` | | Where the importer reaches the API for callbacks and |
| 24 | | `PORT` | `3004 |
| 25 | | `IMPORTER_CONCURRENCY` | `2 |
| 26 | | `IMPORTER_WORKDIR` | `$TMPDIR/ghost-importer |
| 27 | |
| 28 | The API needs `IMPORTER_URL` and the same `IMPORTER_SECRET`, plus ` |
| 29 | |
| 30 | ## Development |
| 31 | |
| 32 | ```sh |
| 33 | bun run dev |
| 34 | bun test |
| 35 | ``` |