diff --git a/.dockerignore b/.dockerignore index 3c3629e64..37d7e7348 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ node_modules +.env diff --git a/.gitignore b/.gitignore index 993c54c01..b6500e26f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ github-graphql-action.json +.env # Logs logs diff --git a/entrypoint.js b/entrypoint.js index 8a2a17a82..0cd63096c 100644 --- a/entrypoint.js +++ b/entrypoint.js @@ -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') { diff --git a/samples/pinissue.query.yaml b/samples/pinissue.query.yaml index 8a2510ac7..f2ee85f42 100644 --- a/samples/pinissue.query.yaml +++ b/samples/pinissue.query.yaml @@ -11,5 +11,4 @@ query: ' variables: issueId: type: jq - file: ../workflow/event.json query: '.issue.node_id' diff --git a/samples/pinnedissues.query.yaml b/samples/pinnedissues.query.yaml index 3476ba3c1..5fa21cf00 100644 --- a/samples/pinnedissues.query.yaml +++ b/samples/pinnedissues.query.yaml @@ -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' diff --git a/samples/repository-jq.query.yaml b/samples/repository-jq.query.yaml index 511940492..9512dd9f8 100644 --- a/samples/repository-jq.query.yaml +++ b/samples/repository-jq.query.yaml @@ -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'