Configure Linear CI/CD integration with GitHub Actions and testing.
Use when setting up automated testing, configuring CI pipelines,
or integrating Linear sync into your build process.
Trigger with phrases like "linear CI", "linear GitHub Actions",
"linear automated tests", "CI linear pipeline", "linear CI/CD".
Integrate Linear into GitHub Actions CI/CD pipelines: run integration tests against the Linear API, automatically link PRs to issues, transition issue states on PR events, and create Linear issues from build failures.
Prerequisites
GitHub repository with Actions enabled
Linear API key stored as GitHub secret
npm/pnpm project with @linear/sdk configured
Instructions
Step 1: Store Secrets in GitHub
# Using GitHub CLI
gh secret set LINEAR_API_KEY --body "lin_api_xxxxxxxxxxxx"
gh secret set LINEAR_WEBHOOK_SECRET --body "whsec_xxxxxxxxxxxx"
# Store team ID for CI-created issues
gh variable set LINEAR_TEAM_ID --body "team-uuid-here"
// tests/linear.integration.test.ts
import { describe, it, expect, beforeAll, afterAll } from "vitest";
import { LinearClient } from "@linear/sdk";
describe("Linear Integration", () => {
let client: LinearClient;
let teamId: string;
const cleanup: string[] = [];
beforeAll(async () => {
const apiKey = process.env.LINEAR_API_KEY;
if (!apiKey) throw new Error("LINEAR_API_KEY required for integration tests");
client = new LinearClient({ apiKey });
const teams = await client.teams();
teamId = teams.nodes[0].id;
});
afterAll(async () => {
for (const id of cleanup) {
try { await client.deleteIssue(id); } catch {}
}
});
it("authenticates successfully", async () => {
const viewer = await client.viewer;
expect(viewer.name).toBeDefined();
expect(viewer.email).toBeDefined();
});
it("creates an issue", async () => {
const result = await client.createIssue({
teamId,
title: `[CI] ${new Date().toISOString()}`,
description: "Created by CI pipeline",
});
expect(result.success).toBe(true);
const issue = await result.issue;
expect(issue?.identifier).toBeDefined();
if (issue) cleanup.push(issue.id);
});
it("queries issues with filtering", async () => {
const issues = await client.issues({
first: 10,
filter: { team: { id: { eq: teamId } } },
});
expect(issues.nodes.length).toBeGreaterThan(0);
});
it("lists workflow states", async () => {
const teams = await client.teams();
const states = await teams.nodes[0].states();
expect(states.nodes.length).toBeGreaterThan(0);
expect(states.nodes.some(s => s.type === "completed")).toBe(true);
});
});
Step 4: PR-to-Issue Linking Workflow
Automatically update Linear issues when PRs are opened, merged, or closed. Extracts issue identifiers from branch names (e.g., feature/ENG-123-description).