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

Fixes https://github.com/cloudflare/pages-action/issues/41
This commit is contained in:
Ian VanSchooten 2022-12-20 12:24:31 -05:00 committed by GitHub
parent ce39707424
commit 226d2ba38e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 4 deletions

View file

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

4
package-lock.json generated
View file

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

View file

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