Skip to content

Commit 7cb29f7

Browse files
committed
feat: send default branch
1 parent 902b613 commit 7cb29f7

File tree

4 files changed

+40
-5
lines changed

4 files changed

+40
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,18 @@ jobs:
2121
id: upload-json-openapi-spec
2222
uses: ./
2323
with:
24-
api-key: ${{ secrets.HEY_API_TOKEN }}
24+
# api-key: ${{ secrets.HEY_API_TOKEN }}
25+
api-key: ${{ secrets.HEY_API_PROJECT_LOCAL }}
26+
base-url: https://grouse-factual-internally.ngrok-free.app
2527
dry-run: true
2628
path-to-file: ./openapi.json
2729

2830
- name: Upload YAML OpenAPI spec
2931
id: upload-yaml-openapi-spec
3032
uses: ./
3133
with:
32-
api-key: ${{ secrets.HEY_API_TOKEN }}
34+
# api-key: ${{ secrets.HEY_API_TOKEN }}
35+
api-key: ${{ secrets.HEY_API_PROJECT_LOCAL }}
36+
base-url: https://grouse-factual-internally.ngrok-free.app
3337
dry-run: true
3438
path-to-file: ./openapi.yaml

dist/index.js

Lines changed: 15 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/upload.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,21 @@ export async function upload({
5858
: 'application/json'
5959
})
6060

61+
const repository = process.env.GITHUB_REPOSITORY
62+
63+
const response = await fetch(`https://api.github.com/repos/${repository}`, {
64+
method: 'GET',
65+
headers: {
66+
Authorization: `Bearer ${process.env.GITHUB_TOKEN}`
67+
}
68+
})
69+
70+
let defaultBranch
71+
if (response.ok) {
72+
const data = await response.json()
73+
defaultBranch = data.default_branch
74+
}
75+
6176
const { error } = await postV1Specifications({
6277
auth: apiKey,
6378
baseUrl: baseUrl || 'https://api.heyapi.dev',
@@ -68,12 +83,14 @@ export async function upload({
6883
branch_base: process.env.GITHUB_BASE_REF,
6984
ci_platform: 'github',
7085
commit_sha: commitSha,
86+
// @ts-expect-error
87+
default_branch: defaultBranch,
7188
dry_run: dryRun,
7289
event_name: process.env.GITHUB_EVENT_NAME,
7390
job: process.env.GITHUB_JOB,
7491
ref: process.env.GITHUB_REF,
7592
ref_type: process.env.GITHUB_REF_TYPE,
76-
repository: process.env.GITHUB_REPOSITORY,
93+
repository,
7794
run_id: process.env.GITHUB_RUN_ID,
7895
run_number: process.env.GITHUB_RUN_NUMBER,
7996
specification,

0 commit comments

Comments
 (0)