Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion bin/action.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -93151,6 +93151,17 @@ async function postChannelSuccessComment(github, context, result, commit) {
core.endGroup();
}

function getProjectIdByAlias(alias) {
try {
const firebaserc = JSON.parse(fs.readFileSync(".firebaserc", {
encoding: 'utf-8'
}));
return firebaserc.projects[alias];
} catch (e) {
return undefined;
}
}

/**
* Copyright 2020 Google LLC
*
Expand Down Expand Up @@ -93216,7 +93227,9 @@ async function run() {
throw Error(deployment.error);
}
core.endGroup();
const hostname = target ? `${target}.web.app` : `${projectId}.web.app`;
// ProjectId may be an alias. Try to get the real project id from .firebaserc
const parsedProjectId = getProjectIdByAlias(projectId) || projectId;
const hostname = target ? `${target}.web.app` : `${parsedProjectId}.web.app`;
const url = `https://${hostname}/`;
await finish({
details_url: url,
Expand All @@ -93226,6 +93239,9 @@ async function run() {
summary: `[${hostname}](${url})`
}
});
core.setOutput("urls", [url]);
core.setOutput("expire_time", undefined);
core.setOutput("details_url", url);
return;
}
const channelId = getChannelId(configuredChannelId, github.context);
Expand Down
10 changes: 10 additions & 0 deletions src/getProjectIdByAlias.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { readFileSync } from "fs";

export function getProjectIdByAlias(alias: string): string {
try {
const firebaserc = JSON.parse(readFileSync(".firebaserc", { encoding: 'utf-8' }));
return firebaserc.projects[alias];
} catch (e) {
return undefined;
}
}
13 changes: 12 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
getURLsMarkdownFromChannelDeployResult,
postChannelSuccessComment,
} from "./postOrUpdateComment";
import { getProjectIdByAlias } from "./getProjectIdByAlias";

// Inputs defined in action.yml
const expires = getInput("expires");
Expand Down Expand Up @@ -99,8 +100,13 @@ async function run() {
}
endGroup();

const hostname = target ? `${target}.web.app` : `${projectId}.web.app`;
// ProjectId may be an alias. Try to get the real project id from .firebaserc
const parsedProjectId = getProjectIdByAlias(projectId) || projectId;
const hostname = target
? `${target}.web.app`
: `${parsedProjectId}.web.app`;
const url = `https://${hostname}/`;

await finish({
details_url: url,
conclusion: "success",
Expand All @@ -109,6 +115,11 @@ async function run() {
summary: `[${hostname}](${url})`,
},
});

setOutput("urls", [url]);
setOutput("expire_time", undefined);
setOutput("details_url", url);

return;
}

Expand Down