@@ -22,11 +22,11 @@ import {
2222 startGroup ,
2323} from "@actions/core" ;
2424import { context , GitHub } from "@actions/github" ;
25+ import { existsSync } from "fs" ;
26+ import { createCheck } from "./createCheck" ;
2527import { createGacFile } from "./createGACFile" ;
26- import { deploy , ErrorResult , deployProductionSite } from "./deploy" ;
28+ import { deploy , deployProductionSite , ErrorResult } from "./deploy" ;
2729import { getChannelId } from "./getChannelId" ;
28- import { installFirebaseCLI } from "./installFirebaseCLI" ;
29- import { createCheck } from "./createCheck" ;
3030import { postOrUpdateComment } from "./postOrUpdateComment" ;
3131
3232// Inputs defined in action.yml
@@ -39,6 +39,7 @@ const configuredChannelId = getInput("channelId");
3939const isProductionDeploy = configuredChannelId === "live" ;
4040const token = process . env . GITHUB_TOKEN || getInput ( "repoToken" ) ;
4141const github = token ? new GitHub ( token ) : undefined ;
42+ const entryPoint = getInput ( "entryPoint" ) ;
4243
4344async function run ( ) {
4445 const isPullRequest = ! ! context . payload . pull_request ;
@@ -49,21 +50,36 @@ async function run() {
4950 }
5051
5152 try {
52- startGroup ( "Setting up Firebase" ) ;
53- const firebase = await installFirebaseCLI ( ) ;
53+ startGroup ( "Verifying firebase.json exists" ) ;
54+
55+ if ( entryPoint !== "." ) {
56+ console . log ( `Changing to directory: ${ entryPoint } ` ) ;
57+ try {
58+ process . chdir ( entryPoint ) ;
59+ } catch ( err ) {
60+ throw Error ( `Error changing to directory ${ entryPoint } : ${ err } ` ) ;
61+ }
62+ }
63+
64+ if ( existsSync ( "./firebase.json" ) ) {
65+ console . log ( "firebase.json file found. Continuing deploy." ) ;
66+ } else {
67+ throw Error (
68+ "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."
69+ ) ;
70+ }
5471 endGroup ( ) ;
5572
5673 startGroup ( "Setting up CLI credentials" ) ;
5774 const gacFilename = await createGacFile ( googleApplicationCredentials ) ;
75+ console . log (
76+ "Created a temporary file with Application Default Credentials."
77+ ) ;
5878 endGroup ( ) ;
5979
6080 if ( isProductionDeploy ) {
6181 startGroup ( "Deploying to production site" ) ;
62- const deployment = await deployProductionSite (
63- firebase ,
64- gacFilename ,
65- projectId
66- ) ;
82+ const deployment = await deployProductionSite ( gacFilename , projectId ) ;
6783 if ( deployment . status === "error" ) {
6884 throw Error ( ( deployment as ErrorResult ) . error ) ;
6985 }
@@ -84,7 +100,7 @@ async function run() {
84100 const channelId = getChannelId ( configuredChannelId , context ) ;
85101
86102 startGroup ( `Deploying to Firebase preview channel ${ channelId } ` ) ;
87- const deployment = await deploy ( firebase , gacFilename , {
103+ const deployment = await deploy ( gacFilename , {
88104 projectId,
89105 expires,
90106 channelId,
0 commit comments