Skip to content

Commit bb7817d

Browse files
committed
fixing min.js
1 parent a539371 commit bb7817d

File tree

1 file changed

+84
-94
lines changed

1 file changed

+84
-94
lines changed

bin/action.min.js

Lines changed: 84 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -87331,26 +87331,6 @@ exports.getOctokit = getOctokit;
8733187331

8733287332
});
8733387333

87334-
// create a check and return a function that updates (completes) it
87335-
async function createCheck(github, context) {
87336-
var _context$payload$pull;
87337-
const check = await github.rest.checks.create({
87338-
...context.repo,
87339-
name: "Deploy Preview",
87340-
head_sha: (_context$payload$pull = context.payload.pull_request) == null ? void 0 : _context$payload$pull.head.sha,
87341-
status: "in_progress"
87342-
});
87343-
return async details => {
87344-
await github.rest.checks.update({
87345-
...context.repo,
87346-
check_run_id: check.data.id,
87347-
completed_at: new Date().toISOString(),
87348-
status: "completed",
87349-
...details
87350-
});
87351-
};
87352-
}
87353-
8735487334
// Copyright Joyent, Inc. and other Node contributors.
8735587335
//
8735687336
// Permission is hereby granted, free of charge, to any person obtaining a
@@ -91689,6 +91669,15 @@ module.exports.setGracefulCleanup = setGracefulCleanup;
9168991669
// Set up Google Application Credentials for use by the Firebase CLI
9169091670
// https://cloud.google.com/docs/authentication/production#finding_credentials_automatically
9169191671
async function createGacFile(googleApplicationCredentials) {
91672+
try {
91673+
if (fs.existsSync(googleApplicationCredentials)) {
91674+
return googleApplicationCredentials;
91675+
}
91676+
} catch (e) {
91677+
console.log("debug: failed checking file existence with error %O", e);
91678+
// googleApplicationCredentials is not a path to a file
91679+
}
91680+
9169291681
const tmpFile = tmp.fileSync({
9169391682
postfix: ".json"
9169491683
});
@@ -93128,9 +93117,10 @@ async function postChannelSuccessComment(github, context, result, commit) {
9312893117
}
9312993118
}
9313093119
} catch (e) {
93131-
console.log("Error checking for previous comments: " + e.message);
93120+
console.error("Error checking for previous comments: " + e.message);
9313293121
}
93133-
if (commentId) {
93122+
if (!!commentId) {
93123+
console.log("Found existing comment.");
9313493124
try {
9313593125
await github.rest.issues.updateComment({
9313693126
...context.repo,
@@ -93140,12 +93130,12 @@ async function postChannelSuccessComment(github, context, result, commit) {
9314093130
} catch (e) {
9314193131
commentId = null;
9314293132
}
93143-
}
93144-
if (!commentId) {
93133+
} else {
93134+
console.log("New comment will be created.");
9314593135
try {
9314693136
await github.rest.issues.createComment(comment);
9314793137
} catch (e) {
93148-
console.log(`Error creating comment: ${e.message}`);
93138+
console.error(`Error creating comment: ${e.message}`);
9314993139
}
9315093140
}
9315193141
core.endGroup();
@@ -93173,18 +93163,12 @@ const googleApplicationCredentials = core.getInput("firebaseServiceAccount", {
9317393163
required: true
9317493164
});
9317593165
const configuredChannelId = core.getInput("channelId");
93176-
const isProductionDeploy = configuredChannelId === "live";
9317793166
const token = process.env.GITHUB_TOKEN || core.getInput("repoToken");
9317893167
const octokit = token ? github.getOctokit(token) : undefined;
9317993168
const entryPoint = core.getInput("entryPoint");
9318093169
const target = core.getInput("target");
9318193170
const firebaseToolsVersion = core.getInput("firebaseToolsVersion");
9318293171
async function run() {
93183-
const isPullRequest = !!github.context.payload.pull_request;
93184-
let finish = details => console.log(details);
93185-
if (token && isPullRequest) {
93186-
finish = await createCheck(octokit, github.context);
93187-
}
9318893172
try {
9318993173
core.startGroup("Verifying firebase.json exists");
9319093174
if (entryPoint !== ".") {
@@ -93198,79 +93182,85 @@ async function run() {
9319893182
if (fs.existsSync("./firebase.json")) {
9319993183
console.log("firebase.json file found. Continuing deploy.");
9320093184
} else {
93201-
throw Error("firebase.json file not found. If your firebase.json file is not in the root of your repo, edit the entryPoint option of this GitHub action.");
93185+
console.warn("firebase.json file not found. If your firebase.json file is not in the root of your repo, edit the entryPoint option of this GitHub action.");
9320293186
}
9320393187
core.endGroup();
9320493188
core.startGroup("Setting up CLI credentials");
93189+
console.log("validating passed credentials: %s", googleApplicationCredentials);
9320593190
const gacFilename = await createGacFile(googleApplicationCredentials);
93206-
console.log("Created a temporary file with Application Default Credentials.");
93191+
console.log("generated credentials: %s", gacFilename);
93192+
if (gacFilename !== googleApplicationCredentials) {
93193+
console.log("Created a temporary file with Application Default Credentials.");
93194+
}
9320793195
core.endGroup();
93208-
if (isProductionDeploy) {
93196+
if (configuredChannelId === "live") {
9320993197
core.startGroup("Deploying to production site");
93210-
const deployment = await deployProductionSite(gacFilename, {
93211-
projectId,
93212-
target,
93213-
firebaseToolsVersion
93214-
});
93215-
if (deployment.status === "error") {
93216-
throw Error(deployment.error);
93217-
}
93198+
await deployToProduction(gacFilename);
93199+
core.endGroup();
93200+
} else {
93201+
const channelId = getChannelId(configuredChannelId, github.context);
93202+
core.startGroup(`Deploying to Firebase preview channel ${channelId}`);
93203+
await deployToPreviewChannel(gacFilename, channelId);
9321893204
core.endGroup();
93219-
const hostname = target ? `${target}.web.app` : `${projectId}.web.app`;
93220-
const url = `https://${hostname}/`;
93221-
await finish({
93222-
details_url: url,
93223-
conclusion: "success",
93224-
output: {
93225-
title: `Production deploy succeeded`,
93226-
summary: `[${hostname}](${url})`
93227-
}
93228-
});
93229-
return;
93230-
}
93231-
const channelId = getChannelId(configuredChannelId, github.context);
93232-
core.startGroup(`Deploying to Firebase preview channel ${channelId}`);
93233-
const deployment = await deployPreview(gacFilename, {
93234-
projectId,
93235-
expires,
93236-
channelId,
93237-
target,
93238-
firebaseToolsVersion
93239-
});
93240-
if (deployment.status === "error") {
93241-
throw Error(deployment.error);
93242-
}
93243-
core.endGroup();
93244-
const {
93245-
expireTime,
93246-
urls
93247-
} = interpretChannelDeployResult(deployment);
93248-
core.setOutput("urls", urls);
93249-
core.setOutput("expire_time", expireTime);
93250-
core.setOutput("details_url", urls[0]);
93251-
const urlsListMarkdown = urls.length === 1 ? `[${urls[0]}](${urls[0]})` : urls.map(url => `- [${url}](${url})`).join("\n");
93252-
if (token && isPullRequest && !!octokit) {
93253-
var _context$payload$pull;
93254-
const commitId = (_context$payload$pull = github.context.payload.pull_request) == null ? void 0 : _context$payload$pull.head.sha.substring(0, 7);
93255-
await postChannelSuccessComment(octokit, github.context, deployment, commitId);
9325693205
}
93257-
await finish({
93258-
details_url: urls[0],
93259-
conclusion: "success",
93260-
output: {
93261-
title: `Deploy preview succeeded`,
93262-
summary: getURLsMarkdownFromChannelDeployResult(deployment)
93263-
}
93264-
});
9326593206
} catch (e) {
9326693207
core.setFailed(e.message);
93267-
await finish({
93268-
conclusion: "failure",
93269-
output: {
93270-
title: "Deploy preview failed",
93271-
summary: `Error: ${e.message}`
93272-
}
93273-
});
9327493208
}
93209+
return undefined;
93210+
}
93211+
async function deployToProduction(gacFilePath) {
93212+
const deployment = await deployProductionSite(gacFilePath, {
93213+
projectId,
93214+
target,
93215+
firebaseToolsVersion
93216+
});
93217+
if (deployment.status === "error") {
93218+
throw Error(deployment.error);
93219+
}
93220+
const hostname = target ? `${target}.web.app` : `${projectId}.web.app`;
93221+
const url = `https://${hostname}/`;
93222+
console.log({
93223+
details_url: url,
93224+
conclusion: "success",
93225+
output: {
93226+
title: `Production deploy succeeded`,
93227+
summary: `[${hostname}](${url})`
93228+
}
93229+
});
93230+
return undefined;
93231+
}
93232+
async function deployToPreviewChannel(gacFilePath, channelId) {
93233+
const deployment = await deployPreview(gacFilePath, {
93234+
projectId,
93235+
expires,
93236+
channelId,
93237+
target,
93238+
firebaseToolsVersion
93239+
});
93240+
if (deployment.status === "error") {
93241+
throw Error(deployment.error);
93242+
}
93243+
const {
93244+
expireTime,
93245+
urls
93246+
} = interpretChannelDeployResult(deployment);
93247+
core.setOutput("urls", urls);
93248+
core.setOutput("expire_time", expireTime);
93249+
core.setOutput("details_url", urls[0]);
93250+
const urlsListMarkdown = urls.length === 1 ? `[${urls[0]}](${urls[0]})` : urls.map(url => `- [${url}](${url})`).join("\n");
93251+
if (token && !!github.context.payload.pull_request && !!octokit) {
93252+
var _context$payload$pull;
93253+
const commitId = (_context$payload$pull = github.context.payload.pull_request) == null ? void 0 : _context$payload$pull.head.sha.substring(0, 7);
93254+
await postChannelSuccessComment(octokit, github.context, deployment, commitId);
93255+
}
93256+
console.log({
93257+
details_url: urls[0],
93258+
conclusion: "success",
93259+
output: {
93260+
title: `Deploy preview succeeded`,
93261+
summary: getURLsMarkdownFromChannelDeployResult(deployment)
93262+
}
93263+
});
93264+
return undefined;
9327593265
}
9327693266
run();

0 commit comments

Comments
 (0)