Skip to content

Commit 6813614

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

File tree

4 files changed

+61
-5
lines changed

4 files changed

+61
-5
lines changed

.github/workflows/ci.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,25 @@ jobs:
2020
- name: Upload JSON OpenAPI spec
2121
id: upload-json-openapi-spec
2222
uses: ./
23+
env:
24+
API_KEY: ${{ secrets.HEY_API_PROJECT_LOCAL }}
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2326
with:
24-
api-key: ${{ secrets.HEY_API_TOKEN }}
27+
# api-key: ${{ secrets.HEY_API_TOKEN }}
28+
api-key: ${{ secrets.HEY_API_PROJECT_LOCAL }}
29+
base-url: https://grouse-factual-internally.ngrok-free.app
2530
dry-run: true
2631
path-to-file: ./openapi.json
2732

2833
- name: Upload YAML OpenAPI spec
2934
id: upload-yaml-openapi-spec
3035
uses: ./
36+
env:
37+
API_KEY: ${{ secrets.HEY_API_PROJECT_LOCAL }}
38+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3139
with:
32-
api-key: ${{ secrets.HEY_API_TOKEN }}
40+
# api-key: ${{ secrets.HEY_API_TOKEN }}
41+
api-key: ${{ secrets.HEY_API_PROJECT_LOCAL }}
42+
base-url: https://grouse-factual-internally.ngrok-free.app
3343
dry-run: true
3444
path-to-file: ./openapi.yaml

dist/index.js

Lines changed: 23 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: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,28 @@ 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+
console.log('🔥🔥🔥🔥🔥')
72+
console.log('ok?', response.ok)
73+
console.log('token?', !!process.env.GITHUB_TOKEN)
74+
if (response.ok) {
75+
const data = await response.json()
76+
console.log(data)
77+
defaultBranch = data.default_branch
78+
} else {
79+
const data = await response.json()
80+
console.log(data)
81+
}
82+
6183
const { error } = await postV1Specifications({
6284
auth: apiKey,
6385
baseUrl: baseUrl || 'https://api.heyapi.dev',
@@ -68,12 +90,14 @@ export async function upload({
6890
branch_base: process.env.GITHUB_BASE_REF,
6991
ci_platform: 'github',
7092
commit_sha: commitSha,
93+
// @ts-expect-error
94+
default_branch: defaultBranch,
7195
dry_run: dryRun,
7296
event_name: process.env.GITHUB_EVENT_NAME,
7397
job: process.env.GITHUB_JOB,
7498
ref: process.env.GITHUB_REF,
7599
ref_type: process.env.GITHUB_REF_TYPE,
76-
repository: process.env.GITHUB_REPOSITORY,
100+
repository,
77101
run_id: process.env.GITHUB_RUN_ID,
78102
run_number: process.env.GITHUB_RUN_NUMBER,
79103
specification,

0 commit comments

Comments
 (0)