Do not create octokit if no github token (#42)

Fixes https://github.com/cloudflare/pages-action/issues/41
pull/37/head
Ian VanSchooten 2 years ago committed by GitHub
parent ce39707424
commit 226d2ba38e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -22067,7 +22067,7 @@ try {
const directory = (0, import_core.getInput)("directory", { required: true }); const directory = (0, import_core.getInput)("directory", { required: true });
const gitHubToken = (0, import_core.getInput)("gitHubToken", { required: false }); const gitHubToken = (0, import_core.getInput)("gitHubToken", { required: false });
const branch = (0, import_core.getInput)("branch", { required: false }); const branch = (0, import_core.getInput)("branch", { required: false });
const octokit = (0, import_github.getOctokit)(gitHubToken); let octokit;
const getProject = async () => { const getProject = async () => {
const response = await (0, import_undici.fetch)( const response = await (0, import_undici.fetch)(
`https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`, `https://api.cloudflare.com/client/v4/accounts/${accountId}/pages/projects/${projectName}`,
@ -22133,6 +22133,7 @@ try {
return; return;
} }
const project = await getProject(); const project = await getProject();
octokit = (0, import_github.getOctokit)(gitHubToken);
const githubBranch = import_process.env.GITHUB_REF_NAME; const githubBranch = import_process.env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === project.production_branch; const productionEnvironment = githubBranch === project.production_branch;
let environmentName; let environmentName;

4
package-lock.json generated

@ -1,12 +1,12 @@
{ {
"name": "pages-action", "name": "pages-action",
"version": "1.0.0", "version": "1.2.0",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "pages-action", "name": "pages-action",
"version": "1.0.0", "version": "1.2.0",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@actions/core": "^1.10.0", "@actions/core": "^1.10.0",

@ -13,7 +13,7 @@ try {
const gitHubToken = getInput("gitHubToken", { required: false }); const gitHubToken = getInput("gitHubToken", { required: false });
const branch = getInput("branch", { required: false }); const branch = getInput("branch", { required: false });
const octokit = getOctokit(gitHubToken); let octokit;
const getProject = async () => { const getProject = async () => {
const response = await fetch( const response = await fetch(
@ -96,6 +96,7 @@ try {
} }
const project = await getProject(); const project = await getProject();
octokit = getOctokit(gitHubToken);
const githubBranch = env.GITHUB_REF_NAME; const githubBranch = env.GITHUB_REF_NAME;
const productionEnvironment = githubBranch === project.production_branch; const productionEnvironment = githubBranch === project.production_branch;

Loading…
Cancel
Save