add test action, prevent failure on empty options

This commit is contained in:
Piotr Kwiecinski 2023-05-04 19:22:57 +02:00
parent f80227ccd3
commit b74d35cf2b
2 changed files with 26 additions and 5 deletions

17
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,17 @@
name: 'build-test'
on: # rebuild any PRs and main branch changes
pull_request:
push:
branches:
- master
- 'releases/*'
jobs:
test: # make sure the action works on a clean machine without building
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./
with:
dep: list
deployer-version: "7.3.0"

View file

@ -109,12 +109,16 @@ async function dep() {
let ansi = core.getBooleanInput('ansi') ? '--ansi' : '--no-ansi'
let verbosity = core.getInput('verbosity')
let options = []
try {
for (let [key, value] in Object.entries(JSON.parse(core.getInput('options')))) {
options.push('-o', `${key}=${value}`)
let optionsInput = core.getInput('options');
if (optionsInput !== '') {
try {
for (let [key, value] in Object.entries(JSON.parse(optionsInput))) {
options.push('-o', `${key}=${value}`)
}
} catch (e) {
throw new Error('Invalid JSON in options')
}
} catch (e) {
throw new Error('Invalid JSON in options')
}
try {