Skip to content

Commit

Permalink
fix output formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
joao-zanutto committed Jul 16, 2024
1 parent 0247bad commit bd1665f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ jobs:
id: get-selected-step
uses: ./
with:
format: 'list'
ignore: api,worker2
format: 'json'

consumer:
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- uses: actions/checkout@v4

- id: get-selected-step
uses: joao-zanutto/get-selected@v1
uses: joao-zanutto/get-selected@v1.1.1

- run: echo ${{ steps.get-selected-step.outputs.selected }}
```
Expand All @@ -56,7 +56,7 @@ jobs:
- uses: actions/checkout@v4

- id: get-selected-step
uses: joao-zanutto/get-selected@v1
uses: joao-zanutto/get-selected@v1.1.1

consume-on-another-job:
runs-on: ubuntu-latest
Expand Down
6 changes: 2 additions & 4 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.

6 changes: 2 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,13 @@ async function run() {
try {
// TODO: Assert event is workflow_dispatch
const format = core.getInput('format')
core.info(format)

const separator =
core.getInput('separator') === '' ? ' ' : core.getInput('separator')
core.info(`Using separator "${separator}"`)

const ignoreList = core.getInput('ignore').split(',')
const inputList = github.context.payload.inputs
core.info(`Loaded inputs: ${JSON.stringify(inputList, null, 2)}`)
core.info(`Loaded inputs: ${JSON.stringify(inputList)}`)
core.info(`Ignoring inputs: ${ignoreList}`)

const selected = []
Expand All @@ -28,7 +26,7 @@ async function run() {

if (format === 'list') core.setOutput('selected', selected.join(separator))
else if (format === 'json')
core.setOutput('selected', JSON.stringify(selected, null, 2))
core.setOutput('selected', JSON.stringify(selected))
else core.error('Invalid format. Valid values are: "list" and "json"')
} catch (error) {
core.setFailed(error.message)
Expand Down

0 comments on commit bd1665f

Please sign in to comment.