From 3aec8793f46d4e8cf49a8d59419b18b5f50981a8 Mon Sep 17 00:00:00 2001 From: lowlighter <22963968+lowlighter@users.noreply.github.com> Date: Mon, 26 Oct 2020 22:03:35 +0100 Subject: [PATCH] Use github.context.repo instead of username --- action/dist/index.js | 7 +++++-- action/index.mjs | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/action/dist/index.js b/action/dist/index.js index 9ab70173..096dc396 100644 --- a/action/dist/index.js +++ b/action/dist/index.js @@ -915,6 +915,9 @@ var E_Users_lecoq_Documents_GitHub_gitstats_node_modules_actions_github_lib_gith if (dryrun) console.log(`Dry-run | complete`) else { + //Repository + const repo = github.context.repo.repo + console.log(`Repository | ${repo}`) //Committer token const token = core.getInput("committer_token") || core.getInput("token") console.log(`Committer token | ${token ? "provided" : "missing"}`) @@ -926,13 +929,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:github.context.repo, path:filename}) + const {data} = await rest.repos.getContent({owner:user, 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:github.context.repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, + owner:user, 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 66a6ff37..da9a0c96 100644 --- a/action/index.mjs +++ b/action/index.mjs @@ -121,6 +121,9 @@ if (dryrun) console.log(`Dry-run | complete`) else { + //Repository + const repo = github.context.repo.repo + console.log(`Repository | ${repo}`) //Committer token const token = core.getInput("committer_token") || core.getInput("token") console.log(`Committer token | ${token ? "provided" : "missing"}`) @@ -132,13 +135,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:github.context.repo, path:filename}) + const {data} = await rest.repos.getContent({owner:user, 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:github.context.repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, + owner:user, repo, path:filename, message:`Update ${filename} - [Skip GitHub Action]`, content:Buffer.from(rendered).toString("base64"), ...(sha ? {sha} : {}) })