@@ -6,16 +6,11 @@ import { postV1Specifications } from './client'
66 * Read and upload the provided OpenAPI specification to Hey API.
77 */
88export async function upload ( {
9- apiKey,
109 baseUrl,
1110 dryRun,
1211 pathToFile,
1312 tags
1413} : {
15- /**
16- * Hey API token.
17- */
18- apiKey : string
1914 /**
2015 * Custom service url.
2116 */
@@ -58,8 +53,23 @@ export async function upload({
5853 : 'application/json'
5954 } )
6055
56+ const repository = process . env . GITHUB_REPOSITORY
57+
58+ const response = await fetch ( `https://api.github.com/repos/${ repository } ` , {
59+ method : 'GET' ,
60+ headers : {
61+ Authorization : `Bearer ${ process . env . GITHUB_TOKEN } `
62+ }
63+ } )
64+
65+ let defaultBranch
66+ if ( response . ok ) {
67+ const repo = await response . json ( )
68+ defaultBranch = repo . default_branch
69+ }
70+
6171 const { error } = await postV1Specifications ( {
62- auth : apiKey ,
72+ auth : process . env . API_KEY ,
6373 baseUrl : baseUrl || 'https://api.heyapi.dev' ,
6474 body : {
6575 actor : process . env . GITHUB_ACTOR ,
@@ -68,12 +78,14 @@ export async function upload({
6878 branch_base : process . env . GITHUB_BASE_REF ,
6979 ci_platform : 'github' ,
7080 commit_sha : commitSha ,
81+ // @ts -expect-error
82+ default_branch : defaultBranch ,
7183 dry_run : dryRun ,
7284 event_name : process . env . GITHUB_EVENT_NAME ,
7385 job : process . env . GITHUB_JOB ,
7486 ref : process . env . GITHUB_REF ,
7587 ref_type : process . env . GITHUB_REF_TYPE ,
76- repository : process . env . GITHUB_REPOSITORY ,
88+ repository,
7789 run_id : process . env . GITHUB_RUN_ID ,
7890 run_number : process . env . GITHUB_RUN_NUMBER ,
7991 specification,
0 commit comments