From c7cf5d8212d2f9865d7e70a479c13235ea547536 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 26 Oct 2020 22:26:26 +0100 Subject: [PATCH] Fix repo handling --- action/dist/index.js | 7 +++---- action/index.mjs | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/action/dist/index.js b/action/dist/index.js index 096dc396..793369c9 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -916,8 +916,7 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_actions_github_lib_gith console.log(`Dry-run | complete`) else { //Repository - const repo = github.context.repo.repo - console.log(`Repository | ${repo}`) + console.log(`Repository | ${github.context.repo.owner}/${github.context.repo.repo}`) //Committer token const token = core.getInput("committer_token") || core.getInput("token") console.log(`Committer token | ${token ? "provided" : "missing"}`) @@ -929,13 +928,13 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_actions_github_lib_gith //Retrieve previous render SHA to be able to update file content through API let sha = null try { - const {data} = await rest.repos.getContent({owner:user, repo, path:filename}) + const {data} = await rest.repos.getContent({...github.context.repo, path:filename}) sha = data.sha } catch (error) { console.debug(error) } console.log(`Previous render sha | ${sha || "none"}`) //Update file content through API await rest.repos.createOrUpdateFileContents({ - owner:user, repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, + ...github.context.repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, content:Buffer.from(rendered).toString("base64"), ...(sha ? {sha} : {}) }) diff --git a/action/index.mjs b/action/index.mjs index da9a0c96..30b7bb04 100644 --- a/action/index.mjs +++ b/action/index.mjs @@ -122,8 +122,7 @@ console.log(`Dry-run | complete`) else { //Repository - const repo = github.context.repo.repo - console.log(`Repository | ${repo}`) + console.log(`Repository | ${github.context.repo.owner}/${github.context.repo.repo}`) //Committer token const token = core.getInput("committer_token") || core.getInput("token") console.log(`Committer token | ${token ? "provided" : "missing"}`) @@ -135,13 +134,13 @@ //Retrieve previous render SHA to be able to update file content through API let sha = null try { - const {data} = await rest.repos.getContent({owner:user, repo, path:filename}) + const {data} = await rest.repos.getContent({...github.context.repo, path:filename}) sha = data.sha } catch (error) { console.debug(error) } console.log(`Previous render sha | ${sha || "none"}`) //Update file content through API await rest.repos.createOrUpdateFileContents({ - owner:user, repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, + ...github.context.repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, content:Buffer.from(rendered).toString("base64"), ...(sha ? {sha} : {}) })