-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfetch.ts
More file actions
36 lines (32 loc) · 1 KB
/
Copy pathfetch.ts
File metadata and controls
36 lines (32 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import axios from "axios";
import {
CircleAPIJob,
CircleAPIPipeline,
CircleAPIWorkflow,
Pipeline,
Workflow,
} from "./types";
const BASE_CIRCLE_API_URL = "https://circleci.com/api/v2";
axios.defaults.baseURL = BASE_CIRCLE_API_URL;
axios.defaults.headers.common["Circle-Token"] = process.env.CIRCLE_API_TOKEN;
axios.defaults.headers.common["Content-Type"] = `text/plain`;
export async function fetchPipelines(
branch: string
): Promise<{ items: CircleAPIPipeline[] }> {
const { data } = await axios.get(
`/project/${process.env.PROJECT_SLUG}/pipeline?branch=${branch}`
);
return data;
}
export async function fetchWorkflow(
pipeline: Pipeline
): Promise<{ items: CircleAPIWorkflow[] }> {
const { data } = await axios.get(`/pipeline/${pipeline.id}/workflow`);
return data;
}
export async function fetchJobsForWorkflow(
workflow: Workflow
): Promise<{ items: CircleAPIJob[] }> {
const { data } = await axios.get(`/workflow/${workflow.id}/job`);
return data;
}