Skip to content

Commit cf1f212

Browse files
committed
chore: pass github refs to api
1 parent c8af9ee commit cf1f212

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

src/upload.ts

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import * as core from '@actions/core'
12
import { readFileSync } from 'node:fs'
23

34
/**
@@ -23,18 +24,25 @@ export async function upload(
2324
throw new Error('invalid OpenAPI path')
2425
}
2526

26-
let formData = [
27-
[encodeURIComponent('openapi'), encodeURIComponent(data.toString())]
28-
]
27+
const formData: Record<string, string | number | boolean> = {
28+
github_repo: process.env.GITHUB_REPOSITORY!,
29+
github_repo_id: process.env.GITHUB_REPOSITORY_ID!,
30+
openapi: data.toString()
31+
}
2932

3033
if (dryRun) {
31-
formData = [
32-
...formData,
33-
[encodeURIComponent('dry-run'), encodeURIComponent(dryRun)]
34-
]
34+
formData['dry-run'] = dryRun
3535
}
3636

37-
const body = formData.flatMap(arr => arr.join('=')).join('&')
37+
core.debug(`GitHub repo: ${process.env.GITHUB_REPOSITORY}`)
38+
core.debug(`GitHub repo ID: ${process.env.GITHUB_REPOSITORY_ID}`)
39+
40+
const body = Object.entries(formData)
41+
.flatMap(
42+
([key, value]) =>
43+
`${encodeURIComponent(key)}=${encodeURIComponent(value)}`
44+
)
45+
.join('&')
3846

3947
const response = await fetch(
4048
'https://platform-production-25fb.up.railway.app/api/openapi',

0 commit comments

Comments
 (0)