Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ jobs:
databricks-repo-branch: 'main'
databricks-token: ${{ secrets.DATABRICKS_TOKEN }}
databricks-host: 'https://dbc-89c9e463-7ff5.cloud.databricks.com'
databricks-repo-id: '3704530822795613'
databricks-repo-id: '2811515952360794'
10 changes: 4 additions & 6 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,17 @@ import * as process from 'process'
import {expect, test} from '@jest/globals'
import * as utils from '../src/utils'


test('test runs', () => {
process.env['DATABRICKS_HOST'] = 'https://xyz.cloud.databricks.com'
process.env['DATABRICKS_REPO_ID'] = '3704530822795627'
})
})

test('databricks host', () => {
const host = utils.get_databricks_host()
expect(typeof host).toBe("string")
expect(typeof host).toBe('string')
})


test('databricks repo id', () => {
const host = utils.get_databricks_repo_id()
expect(typeof host).toBe("string")
})
expect(typeof host).toBe('string')
})
19 changes: 11 additions & 8 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

10 changes: 9 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ async function run(): Promise<void> {
)

const status = response.status
core.info(`status code ${status}`)
if (status === 200) {
core.info('Deployed the code successfully')
} else if (status === 401) {
core.info(
'Authentication error, please check your databricks token!'
)
} else {
core.setFailed('Failed to update the repo')
}
} catch (error) {
if (error instanceof Error) core.setFailed(error.message)
if (error instanceof Error) {
core.info(error.message)
core.setFailed(error.message)
}
}
}

Expand Down
10 changes: 3 additions & 7 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,14 @@ import * as core from '@actions/core'

export function get_databricks_host(): string {
const databricks_host_input: string = core.getInput('databricks-host')
const databricks_host_env: string = process.env['DATABRICKS_HOST'] || ''
const databricks_host_env: string = process.env['DATABRICKS_HOST'] ?? ''

if (!databricks_host_input && !databricks_host_env) {
throw new Error(
'databricks-host or DATABRICKS_HOST environment variable must be set.'
)
} else {
return databricks_host_input
? databricks_host_input
: databricks_host_env
return databricks_host_input || databricks_host_env
}
}

Expand All @@ -23,9 +21,7 @@ export function get_databricks_repo_id(): string {
'databricks-repo-id or DATABRICKS_REPO_ID environment variable must be set.'
)
} else {
return databricks_repo_input
? databricks_repo_input
: databricks_repo_env
return databricks_repo_input || databricks_repo_env
}
}

Expand Down