Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:

## Options

### `firebaseServiceAccount` _{string}_ (required)
### `firebaseServiceAccount` _{string}_

This is a service account JSON key. The easiest way to set it up is to run `firebase init hosting:github`. However, it can also be [created manually](./docs/service-account.md).

Expand All @@ -95,6 +95,8 @@ to prevent unintended access to your Firebase project. Set it in the "Secrets" a
of your repository settings and add it as `FIREBASE_SERVICE_ACCOUNT`:
`https://github.com/USERNAME/REPOSITORY/settings/secrets`.

If not provided, the action will attempt to use the default application credentials configured in your environment.

### `repoToken` _{string}_

Adding `repoToken: "${{secrets.GITHUB_TOKEN}}"` lets the action comment on PRs
Expand Down
13 changes: 8 additions & 5 deletions bin/action.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -91689,6 +91689,9 @@ module.exports.setGracefulCleanup = setGracefulCleanup;
// Set up Google Application Credentials for use by the Firebase CLI
// https://cloud.google.com/docs/authentication/production#finding_credentials_automatically
async function createGacFile(googleApplicationCredentials) {
if (!googleApplicationCredentials) {
return "";
}
const tmpFile = tmp.fileSync({
postfix: ".json"
});
Expand Down Expand Up @@ -92958,7 +92961,10 @@ async function execWithCredentials(args, projectId, gacFilename, opts) {
env: {
...process.env,
FIREBASE_DEPLOY_AGENT: "action-hosting-deploy",
GOOGLE_APPLICATION_CREDENTIALS: gacFilename // the CLI will automatically authenticate with this env variable set
...(gacFilename ? {
GOOGLE_APPLICATION_CREDENTIALS: gacFilename
} // the CLI will automatically authenticate with this env variable set
: {})
}
});
} catch (e) {
Expand All @@ -92976,7 +92982,6 @@ async function execWithCredentials(args, projectId, gacFilename, opts) {
}
return deployOutputBuf.length ? deployOutputBuf[deployOutputBuf.length - 1].toString("utf-8") : ""; // output from the CLI
}

async function deployPreview(gacFilename, deployConfig) {
const {
projectId,
Expand Down Expand Up @@ -93171,9 +93176,7 @@ async function postChannelSuccessComment(github, context, result, commit) {
// Inputs defined in action.yml
const expires = core.getInput("expires");
const projectId = core.getInput("projectId");
const googleApplicationCredentials = core.getInput("firebaseServiceAccount", {
required: true
});
const googleApplicationCredentials = core.getInput("firebaseServiceAccount");
const configuredChannelId = core.getInput("channelId");
const isProductionDeploy = configuredChannelId === "live";
const token = process.env.GITHUB_TOKEN || core.getInput("repoToken");
Expand Down
5 changes: 4 additions & 1 deletion src/createGACFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ import { writeSync } from "fs";
// Set up Google Application Credentials for use by the Firebase CLI
// https://cloud.google.com/docs/authentication/production#finding_credentials_automatically
export async function createGacFile(googleApplicationCredentials: string) {
const tmpFile = fileSync({ postfix: ".json" });
if (!googleApplicationCredentials) {
return "";
}

const tmpFile = fileSync({ postfix: ".json" });
writeSync(tmpFile.fd, googleApplicationCredentials);

return tmpFile.name;
Expand Down
4 changes: 3 additions & 1 deletion src/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,9 @@ async function execWithCredentials(
env: {
...process.env,
FIREBASE_DEPLOY_AGENT: "action-hosting-deploy",
GOOGLE_APPLICATION_CREDENTIALS: gacFilename, // the CLI will automatically authenticate with this env variable set
...(gacFilename
? { GOOGLE_APPLICATION_CREDENTIALS: gacFilename } // the CLI will automatically authenticate with this env variable set
: {}),
},
}
);
Expand Down
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@ import {
// Inputs defined in action.yml
const expires = getInput("expires");
const projectId = getInput("projectId");
const googleApplicationCredentials = getInput("firebaseServiceAccount", {
required: true,
});
const googleApplicationCredentials = getInput("firebaseServiceAccount");
const configuredChannelId = getInput("channelId");
const isProductionDeploy = configuredChannelId === "live";
const token = process.env.GITHUB_TOKEN || getInput("repoToken");
Expand Down