diff --git a/index.js b/index.js index 2d99d3a..a204817 100644 --- a/index.js +++ b/index.js @@ -1,15 +1,7 @@ const core = require('@actions/core'); const { Octokit } = require("@octokit/rest"); -try { - const versionPrefix = "v1." - const token = core.getInput('token'); - const version = core.getInput('version'); - const org = core.getInput("org") - const repo = core.getInput("repo") - const octokit = new Octokit({ - auth: token, - }) +async function downloadGofmt(octokit, version, versionPrefix, org, repo) { if (version !== "") { if (!version.startsWith(versionPrefix)) { throw "Specified version " + version + " does not start with required version prefix " + versionPrefix + "." @@ -24,6 +16,22 @@ try { for (let release of releases) { console.log(release) } +} + +try { + const versionPrefix = "v1." + const token = core.getInput('token'); + const version = core.getInput('version'); + const org = core.getInput("org") + const repo = core.getInput("repo") + const octokit = new Octokit({ + auth: token, + }) + downloadGofmt(octokit, version, versionPrefix, org, repo).then(function () { + console.log("Download successful.") + }).catch(reason => function() { + core.setFailed(reason); + }) } catch (error) { core.setFailed(error.message); } \ No newline at end of file