Skip to content
This repository was archived by the owner on Nov 15, 2022. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
.env
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
github-graphql-action.json

.env

# Logs
logs
Expand Down
14 changes: 11 additions & 3 deletions entrypoint.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,18 @@ Toolkit.run(async tools => {
body.variables[key] = tools.inputs[value.name]
} else if (value.type === 'jq') {
// Need to apply jq to a file to retrieve a value
let jsonFile = value.file
let jqQuery = value.query

let result = execSync(`cat ${tools.workspace}/${jsonFile} | jq -j '${jqQuery}'`, {stdio: [this.stdin, this.stdout, this.stderr]})
let jsonFile

if (value.file) {
jsonFile = `${tools.workspace}/${jsonFile}`
} else {
jsonFile = tools.event_path
}

tools.log.debug(`Input file is ${jsonFile}`)

let result = execSync(`cat ${jsonFile} | jq -j '${jqQuery}'`, {stdio: [this.stdin, this.stdout, this.stderr]})
if (value.cast === 'Int') {
body.variables[key] = parseInt(result)
} else if (value.cast === 'Float') {
Expand Down
1 change: 0 additions & 1 deletion samples/pinissue.query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,4 @@ query: '
variables:
issueId:
type: jq
file: ../workflow/event.json
query: '.issue.node_id'
2 changes: 0 additions & 2 deletions samples/pinnedissues.query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ query: '
variables:
owner:
type: jq
file: ../workflow/event.json
query: '.repository.owner.login'
name:
type: jq
file: ../workflow/event.json
query: '.repository.name'
2 changes: 0 additions & 2 deletions samples/repository-jq.query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ query:
variables:
owner:
type: jq
file: ../workflow/event.json
query: '.repository.owner.login'
name:
type: jq
file: ../workflow/event.json
query: '.repository.name'