Skip to content

Commit beddc6c

Browse files
committed
fix: diffing openapi procedure follows default code, not the other way around
1 parent 9e020a5 commit beddc6c

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/main.ts

+22-22
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,15 @@
11
import * as core from '@actions/core'
22
import { wait } from './wait'
33
import { stdout } from 'process'
4-
import { getFileFromBranch } from 'src/utils/getFileFromBranch'
5-
import { diffOpenapiObject } from 'src/utils/diffOpenapiObject'
4+
import { getFileFromBranch } from './utils/get-file-from-branch'
5+
import { diffOpenapiObject } from './utils/diff-openapi-object'
66

77
/**
88
* The main function for the action.
99
* @returns {Promise<void>} Resolves when the action is complete.
1010
*/
1111
export async function run(): Promise<void> {
1212
try {
13-
// parse two openapi files
14-
const baseBranch = process.env.GITHUB_BASE_REF!
15-
const headBranch = process.env.GITHUB_HEAD_REF!
16-
const filePath = './openapi.json'
17-
18-
const baseFile = JSON.parse(
19-
getFileFromBranch(baseBranch, filePath).toString()
20-
)
21-
const headFile = JSON.parse(
22-
getFileFromBranch(headBranch, filePath).toString()
23-
)
24-
25-
console.log('baseFile', baseFile)
26-
console.log('headFile', headFile)
27-
28-
const diff = diffOpenapiObject(baseFile, headFile)
29-
30-
console.log('diff', diff)
31-
const result = JSON.stringify(diff, null, 2)
32-
3313
const ms: string = core.getInput('milliseconds')
3414

3515
// Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
@@ -62,6 +42,26 @@ export async function run(): Promise<void> {
6242
// ---
6343
// `
6444

45+
// parse two openapi files
46+
const baseBranch = process.env.GITHUB_BASE_REF!
47+
const headBranch = process.env.GITHUB_HEAD_REF!
48+
const filePath = './openapi.json'
49+
50+
const baseFile = JSON.parse(
51+
getFileFromBranch(baseBranch, filePath).toString()
52+
)
53+
const headFile = JSON.parse(
54+
getFileFromBranch(headBranch, filePath).toString()
55+
)
56+
57+
console.log('baseFile', baseFile)
58+
console.log('headFile', headFile)
59+
60+
const diff = diffOpenapiObject(baseFile, headFile)
61+
62+
console.log('diff', diff)
63+
const result = JSON.stringify(diff, null, 2)
64+
6565
console.log(result)
6666

6767
core.setOutput('result', result)

0 commit comments

Comments
 (0)