Swift module with just enough GitHub API support for ActionStatus and related tooling.
I'm not even slightly pretending that this is good enough for general purpose use.
- GitHub payload models used by ActionStatus:
Events/EventWorkflows/WorkflowWorkflowRuns/WorkflowRun- Supporting types (
Actor,Author,Commit, etc.)
- Resource resolvers for key endpoints:
EventsResourceWorkflowsResourceWorkflowResource
- Polling helpers built on
JSONSession3.x:Session.repositoryUpdates(...)RepositoryReferenceRepositoryPollConfigurationRepositoryUpdateMessageProcessorUnchangedProcessorMessageReceiver
- Swift tools: 6.2
- Platforms:
- macOS 26+
- Mac Catalyst 26+
- iOS 26+
- tvOS 26+
- watchOS 11+
Add Octoid to your package dependencies:
dependencies: [
.package(url: "https://github.com/elegantchaos/Octoid.git", from: "3.0.0")
]Then add Octoid to the target dependencies that need it.
Create a JSONSession session and consume Octoid's repository update stream.
import Foundation
import Octoid
import JSONSession
let session = Session(
base: URL(string: "https://api.github.com")!,
token: githubToken
)
let stream = session.repositoryUpdates(
for: RepositoryReference(owner: "elegantchaos", name: "Octoid"),
configuration: RepositoryPollConfiguration(interval: .seconds(60))
)
for await update in stream {
switch update {
case .events(let events):
print("events: \(events.count)")
case .workflows(let workflows):
print("workflows: \(workflows.total_count)")
case .workflowRuns(let target, let runs):
print("runs for \(target.name): \(runs.isEmpty ? "no runs" : "has runs")")
case .message(_, let message):
print("api message: \(message)")
case .transportError(_, let description):
print("transport error: \(description)")
}
}Use WorkflowResource in one of three modes:
- By workflow name:
WorkflowResource(name:owner:workflow:) - By workflow ID:
WorkflowResource(name:owner:workflowID:) - All workflows:
WorkflowResource.allWorkflows(name:owner:)
If workflow names are not stable, fetch WorkflowsResource first and use workflows.preferredWorkflow?.id.
See TESTING.md for local and integration test setup.