{"size": 1066, "ext": "js", "max_stars_repo_path": "index.js", "max_stars_repo_name": "ArshPartior/github-actions-post-to-pr", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "index.js", "max_issues_repo_name": "ArshPartior/github-actions-post-to-pr", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "index.js", "max_forks_repo_name": "ArshPartior/github-actions-post-to-pr", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.2083333333, "max_line_length": 87, "alphanum_fraction": 0.6632270169}
const fs = require('fs');
const core = require('@actions/core');
const utils = require('./utils');
const pullRequest = require('./pull_request');



async function run() {
  try { 
    const octokit = utils.getClient();

    const actionEvent = JSON.parse(
      fs.readFileSync(process.env.GITHUB_EVENT_PATH, 'utf8')
    )

    const rawDefinition = core.getInput('post_to_pr_definition');
    var definitions;
    try{
      definitions = JSON.parse(rawDefinition);
    } catch(error) {
      core.setFailed(`Erro parsing json config \n${rawDefinition}\n error : ${error}`);
      return
    }

    definitions = definitions.map(pullRequest.processDefinition)


    if (actionEvent.pull_request) {
      var prMessage = await pullRequest.getPrMessage(octokit, definitions);


      await pullRequest.postPrMessage(
        octokit,
        actionEvent.pull_request.number,
        prMessage
      )
    }

    await utils.uploadArtifacts(definitions);
    await utils.uploadOldArtifacts(definitions);
  } 
  catch (error) {
    core.setFailed(error);
  }
}

run()
