Skip to content

Commit f399710

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

File tree

6 files changed

+64
-5
lines changed

6 files changed

+64
-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: 27 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/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,8 @@
33
*/
44
import { run } from './main'
55

6+
console.log('✅✅✅✅')
7+
console.log('token?', !!process.env.GITHUB_TOKEN)
8+
69
// eslint-disable-next-line @typescript-eslint/no-floating-promises
710
run()

src/main.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import { upload } from './upload'
66
* @returns {Promise<void>} Resolves when the action is complete.
77
*/
88
export async function run(): Promise<void> {
9+
console.log('⏳⏳⏳')
10+
console.log('token?', !!process.env.GITHUB_TOKEN)
911
try {
1012
const apiKey: string = core.getInput('api-key', {
1113
required: true

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)