Skip to content
Merged
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
48 changes: 32 additions & 16 deletions skills/firebase-app-hosting-basics/references/cli_commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
The Firebase CLI provides a comprehensive suite of commands to manage App Hosting resources. These commands are often faster and more scriptable than using the Firebase Console.

## Initialization

### `firebase init apphosting`

- **Purpose**: Interactive command that sets up App Hosting in your local project.
Use this command only if you are able to handle interactive CLI inputs well.
Alternatively, you can manually edit `firebase.json` and `apphosting.yml`.
Expand All @@ -14,42 +16,56 @@ Alternatively, you can manually edit `firebase.json` and `apphosting.yml`.
- Can optionally create a backend if one doesn't exist.

## Backend Management
### `firebase apphosting:backends:create`
- **Purpose**: Creates a new App Hosting backend. Use this when setting up automated deployments via GitHub.
- **Options**:
- `--app <webAppId>`: The ID of an existing Firebase web app to associate with the backend.
- `--backend <backendId>`: The ID of the new backend.
- `--primary-region <location>`: The primary region for the backend.
- `--root-dir <rootDir>`: The root directory for the backend. If omitted, defaults to the root directory of the project.
- `--service-account <service-account>`: The service account used to run the server. If omitted, defaults to the default service account.

### `firebase apphosting:backends:list`

- **Purpose**: Lists all backends in the current project.

### `firebase apphosting:backends:get <backend-id>`

- **Purpose**: Shows details for a specific backend.

### `firebase apphosting:backends:delete <backend-id>`
- **Purpose**: Deletes a backend and its associated resources.

## Rollouts (Deployment)
### `firebase apphosting:rollouts:create <backend-id>`
- **Purpose**: Manually triggers a new rollout (deployment).
- **Options**:
- `--git-branch <branch>`: Deploy the latest commit from a specific branch.
- `--git-commit <commit-hash>`: Deploy a specific commit.
- **Use Case**: Useful for redeploying without code changes, or rolling back to a specific commit.
- **Purpose**: Deletes a backend and its associated resources.

### `firebase apphosting:rollouts:list <backend-id>`

- **Purpose**: Lists the history of rollouts for a backend.

## Secrets Management

App Hosting uses Cloud Secret Manager to securely handle sensitive environment variables (like API keys).

### `firebase apphosting:secrets:set <secret-name>`

- **Purpose**: Creates or updates a secret in Cloud Secret Manager and makes it available to App Hosting.
- **Behavior**: Prompts for the secret value (hidden input).

### `firebase apphosting:secrets:grantaccess <secret-name>`

- **Purpose**: Grants the App Hosting service account permission to access the secret.
- **Note**: Often handled automatically by `secrets:set`, but useful for debugging permission issues or granting access to existing secrets.

## Automated deployment via GitHub (CI/CD)

**IMPORTANT** Only use these commands if you are setting up automated deployments via GitHub. If you are managing deployments using `firebase deploy`, DO NOT use these commands.

### `firebase apphosting:rollouts:create <backend-id>`

- **Purpose**: Manually triggers a new rollout (deployment).
- **Options**:
- `--git-branch <branch>`: Deploy the latest commit from a specific branch.
- `--git-commit <commit-hash>`: Deploy a specific commit.
- **Use Case**: Useful for redeploying without code changes, or rolling back to a specific commit.

### `firebase apphosting:backends:create`

- **Purpose**: Creates a new App Hosting backend. Use this when setting up automated deployments via GitHub.
- **Options**:
- `--app <webAppId>`: The ID of an existing Firebase web app to associate with the backend.
- `--backend <backendId>`: The ID of the new backend.
- `--primary-region <location>`: The primary region for the backend.
- `--root-dir <rootDir>`: The root directory for the backend. If omitted, defaults to the root directory of the project.
- `--service-account <service-account>`: The service account used to run the server. If omitted, defaults to the default service account.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This line adds trailing whitespace at the end of the file, and the file is missing a final newline. This should be removed to ensure clean file formatting. It's also a good practice for text files to end with a single newline character on the last line of content.

Loading