Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Service Usage Consumer role to GitHub Actions service account #6895

Merged
merged 3 commits into from
Mar 26, 2024
Merged
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fixes issue where GitHub actions service account cannot add preview URLs to Auth authorized domains (#6895)
- Release Firestore Emulator 1.19.4. This version fixes a minor bug with reserve ids and adds a `reset` endpoint for Datastore Mode.
1 change: 1 addition & 0 deletions src/gcp/resourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
functionsDeveloper: "roles/cloudfunctions.developer",
hostingAdmin: "roles/firebasehosting.admin",
runViewer: "roles/run.viewer",
serviceUsageConsumer: "roles/serviceusage.serviceUsageConsumer",
};

/**
* Fetches the IAM Policy of a project.
* https://cloud.google.com/resource-manager/reference/rest/v1/projects/getIamPolicy

Check warning on line 22 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param projectIdOrNumber the id of the project whose IAM Policy you want to get
*/
Expand All @@ -31,7 +32,7 @@

/**
* Sets the IAM Policy of a project.
* https://cloud.google.com/resource-manager/reference/rest/v1/projects/setIamPolicy

Check warning on line 35 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param projectIdOrNumber the id of the project for which you want to set a new IAM Policy
* @param newPolicy the new IAM policy for the project
Expand All @@ -53,7 +54,7 @@
}

/**
* Update the IAM Policy of a project to include a service account in a role.

Check warning on line 57 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param projectId the id of the project whose IAM Policy you want to set
* @param serviceAccountName the name of the service account
Expand All @@ -75,7 +76,7 @@
// The way the service account name is formatted in the Policy object
// https://cloud.google.com/iam/docs/reference/rest/v1/Policy
// serviceAccount:my-project-id@appspot.gserviceaccount.com
const newMemberName = `serviceAccount:${fullServiceAccountName.split("/").pop()}`;

Check warning on line 79 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | undefined" of template literal expression

roles.forEach((roleName) => {
let bindingIndex = findIndex(
Expand Down Expand Up @@ -103,7 +104,7 @@
return setIamPolicy(projectId, projectPolicy, "bindings");
}

export async function serviceAccountHasRoles(

Check warning on line 107 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
projectId: string,
serviceAccountName: string,
roles: string[],
Expand All @@ -119,7 +120,7 @@
// The way the service account name is formatted in the Policy object
// https://cloud.google.com/iam/docs/reference/rest/v1/Policy
// serviceAccount:my-project-id@appspot.gserviceaccount.com
const memberName = `serviceAccount:${fullServiceAccountName.split("/").pop()}`;

Check warning on line 123 in src/gcp/resourceManager.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Invalid type "string | undefined" of template literal expression

for (const roleName of roles) {
const binding = projectPolicy.bindings.find((b: Binding) => b.role === roleName);
Expand Down
4 changes: 4 additions & 0 deletions src/init/features/hosting/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
* - Writes GitHub workflow yaml configuration files that reference the newly created secret
* to configure the Deploy to Firebase Hosting GitHub Action
* - https://github.com/marketplace/actions/deploy-to-firebase-hosting
* - https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions

Check warning on line 50 in src/init/features/hosting/github.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Expected only 0 line after block description
*
* @param setup A helper object provided by the `firebase init` command.
* @param config Configuration for the project.

Check warning on line 53 in src/init/features/hosting/github.ts

View workflow job for this annotation

GitHub Actions / lint (20)

@param "config" does not match an existing function parameter
* @param options Command line options.
*/
export async function initGitHub(setup: Setup): Promise<void> {
Expand Down Expand Up @@ -83,10 +83,10 @@

// Get GitHub user Details
const userDetails = await getGitHubUserDetails(ghAccessToken);
const ghUserName = userDetails.login;

Check warning on line 86 in src/init/features/hosting/github.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

logger.info();
logSuccess(`Success! Logged into GitHub as ${bold(ghUserName)}`);

Check warning on line 89 in src/init/features/hosting/github.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `string | number`
logger.info();

// Prompt for repo and validate by getting the public key
Expand Down Expand Up @@ -611,6 +611,10 @@
// https://github.com/firebase/firebase-tools/issues/2732
firebaseRoles.authAdmin,

// Required to add preview URLs to Auth authorized domains
// https://github.com/firebase/firebase-tools/issues/6828
firebaseRoles.serviceUsageConsumer,

// Required for CLI deploys
firebaseRoles.apiKeysViewer,

Expand Down
Loading