{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/revdoku-com/json-schema/revdoku-com-github-sync-schema.json",
  "title": "GithubSync",
  "description": "The GitHub repository of a bucket. The bucket's files are a copy of one branch, or of one folder of it.",
  "x-generated": "2026-11-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/revdoku-com-openapi.json#/components/schemas/GithubSync",
  "type": "object",
  "additionalProperties": false,
  "properties": {
    "id": {
      "type": "string",
      "description": "Link ID."
    },
    "bucket_id": {
      "type": "string"
    },
    "installation_id": {
      "type": "integer",
      "description": "The connected GitHub account (Revdoku GitHub App installation) that reads the repository."
    },
    "repo_owner": {
      "type": "string",
      "description": "The GitHub account or organization that owns the repository."
    },
    "repo_name": {
      "type": "string"
    },
    "repo_full_name": {
      "type": "string",
      "description": "owner/name."
    },
    "repository_url": {
      "type": "string",
      "format": "uri"
    },
    "branch": {
      "type": "string"
    },
    "repo_path": {
      "type": [
        "string",
        "null"
      ],
      "description": "The repository folder that is copied into the bucket folder _repo/. Null: the whole repository."
    },
    "sync_state": {
      "type": "string",
      "enum": [
        "idle",
        "syncing",
        "waiting_locked",
        "error",
        "disconnected"
      ],
      "description": "idle: nothing runs. syncing: a sync runs. waiting_locked: the bucket is locked and the sync tries again later. error: see last_error and next_retry_at. disconnected: the repository is no longer connected."
    },
    "last_error": {
      "anyOf": [
        {
          "$ref": "#/$defs/GithubSyncError"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the last sync failed or waits, or why GitHub disconnected the repository."
    },
    "next_retry_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When a failed sync tries again. Null after the last try: sync again after the cause is fixed."
    },
    "last_synced_at": {
      "type": [
        "string",
        "null"
      ],
      "format": "date-time",
      "description": "When the last sync finished. Null until the first copy is done."
    },
    "last_synced_commit_sha": {
      "type": [
        "string",
        "null"
      ],
      "description": "The commit of the branch that the files show."
    },
    "last_synced_commit_message": {
      "type": [
        "string",
        "null"
      ]
    },
    "auto_publish": {
      "type": "boolean",
      "description": "The site publishes again after each sync. The first publish is publishBucket."
    },
    "skipped_files": {
      "type": "array",
      "description": "Repository files that the last sync left out, for example files that are too large or stored in Git LFS.",
      "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "path",
          "code",
          "reason"
        ],
        "properties": {
          "path": {
            "type": "string"
          },
          "code": {
            "type": [
              "string",
              "null"
            ]
          },
          "reason": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      }
    },
    "auto_publish_error": {
      "anyOf": [
        {
          "$ref": "#/$defs/GithubSyncError"
        },
        {
          "type": "null"
        }
      ],
      "description": "Why the site was not published again after the last sync."
    },
    "dashboard_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "The bucket's GitHub page in the dashboard. It grants no access."
    },
    "created_at": {
      "type": "string",
      "format": "date-time"
    },
    "updated_at": {
      "type": "string",
      "format": "date-time"
    }
  },
  "required": [
    "id",
    "bucket_id",
    "installation_id",
    "repo_owner",
    "repo_name",
    "repo_full_name",
    "repository_url",
    "branch",
    "repo_path",
    "sync_state",
    "last_error",
    "next_retry_at",
    "last_synced_at",
    "last_synced_commit_sha",
    "last_synced_commit_message",
    "auto_publish",
    "skipped_files",
    "auto_publish_error",
    "dashboard_url",
    "created_at",
    "updated_at"
  ],
  "$defs": {
    "GithubSyncError": {
      "type": "object",
      "additionalProperties": false,
      "required": [
        "code",
        "message"
      ],
      "description": "Why a sync or a publish after a sync failed: a stable code and one readable sentence.",
      "properties": {
        "code": {
          "type": "string",
          "description": "For example REMOTE_BRANCH_GONE, GITHUB_REPO_ACCESS_REMOVED, GITHUB_APP_UNINSTALLED or GITHUB_SYNC_FAILED."
        },
        "message": {
          "type": "string"
        }
      }
    }
  }
}