Skip to content

Commit

Permalink
feat: JSON_INPUT as file format (#284)
Browse files Browse the repository at this point in the history
* feat:

- refactor code to accept JSON file format

Contributes to:
https:camelotls/actions-jira-integration/#57

signed-off-by: Giorgos Romanas <[email protected]>
  • Loading branch information
gromanas authored Oct 6, 2021
1 parent d6166f7 commit 4ec0580
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ A GitHub Action to integrate multiple tools with Jira Server and raise relevant
|JIRA_PASSWORD|true|N/A|GitHub secret for the JIRA API token for external access|
|JIRA_PROJECT|true|N/A|The project key for Jira|
|JIRA_URI|true|N/A|The JIRA URI for your organisation|
|INPUT_JSON|true|N/A|The JSON input to be parsed|
|INPUT_JSON|true|N/A|The path where the JSON input to be parsed|
|REPORT_INPUT_KEYS|true|N/A|A list of keys of the input JSON you provide that will be parsed and included in the report|
|ISSUE_TYPE|true|""|Indicates if the JSON to be used for the JIRA REST calls is based on npm audit since there is a need for special treating of the overview report field|
|RUNS_ON_GITHUB|true|true|Indicates if the action runs on GitHub or locally, on a Docker container, for testing purporses|
Expand Down Expand Up @@ -79,7 +79,7 @@ jobs:
JIRA_USER: ${{ secrets.JIRA_USER }}
JIRA_PASSWORD: ${{ secrets.JIRA_PASSWORD }}
# the job with id npm_audit outputs a variable called npm_audit_json
INPUT_JSON: ${{ steps.npm_audit.outputs.npm_audit_json }}
INPUT_JSON: './report.json'
JIRA_PROJECT: ${{ env.JIRA_PROJECT }}
JIRA_URI: 'jira.camelot.global'
REPORT_INPUT_KEYS: |
Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ inputs:
description: "The Jira URI used for the REST API to make the requests to"
required: true
INPUT_JSON:
description: "The JSON input to be parsed"
description: "The path where the JSON input to be parsed"
required: true
REPORT_INPUT_KEYS:
description: "A list of keys of the input JSON you provide that will be parsed and included in the report"
Expand Down
5 changes: 4 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const REPORT_INPUT_KEYS = utils.getInput('REPORT_INPUT_KEYS');
const PRIORITY_MAPPER = utils.getInput('PRIORITY_MAPPER');
const UPLOAD_FILES = utils.getInput('UPLOAD_FILES') === 'true';
const UPLOAD_FILES_PATH = (core.getInput('UPLOAD_FILES_PATH') || process.env.UPLOAD_FILES_PATH) === '';
const INPUT_JSON = utils.getInput('INPUT_JSON') || process.env.INPUT_JSON;

let jiraAuthHeaderValue;

Expand Down Expand Up @@ -150,7 +151,9 @@ const kickOffAction = async (inputJson) => {
await logout(jiraAuthHeaderValue);
};

const reportInputFile = fs.readFileSync(INPUT_JSON, 'utf8');

(async () => {
utils.folderCleanup(config.UTILS.PAYLOADS_DIR);
await kickOffAction(utils.getInput('INPUT_JSON'));
await kickOffAction(reportInputFile);
})();

0 comments on commit 4ec0580

Please sign in to comment.