|
1 | 1 | import * as core from '@actions/core'
|
2 | 2 | import { wait } from './wait'
|
3 | 3 | 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' |
6 | 6 |
|
7 | 7 | /**
|
8 | 8 | * The main function for the action.
|
9 | 9 | * @returns {Promise<void>} Resolves when the action is complete.
|
10 | 10 | */
|
11 | 11 | export async function run(): Promise<void> {
|
12 | 12 | 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 |
| - |
33 | 13 | const ms: string = core.getInput('milliseconds')
|
34 | 14 |
|
35 | 15 | // Debug logs are only output if the `ACTIONS_STEP_DEBUG` secret is true
|
@@ -62,6 +42,26 @@ export async function run(): Promise<void> {
|
62 | 42 | // ---
|
63 | 43 | // `
|
64 | 44 |
|
| 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 | + |
65 | 65 | console.log(result)
|
66 | 66 |
|
67 | 67 | core.setOutput('result', result)
|
|
0 commit comments