Live bereitstellen & Vorschaukanäle über GitHub-Pull-Anfragen
Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Sie können Bereitstellungen für Firebase Hosting über eine GitHub-Aktion einbinden. Das kann diese GitHub-Aktion für Sie tun:
Für jeden Pull-Request in Ihrem GitHub-Repository wird ein neuer Preview-Channel (und die zugehörige Preview-URL) erstellt.
Fügt dem Pull-Request einen Kommentar mit der Vorschau-URL hinzu, damit Sie und jeder Prüfer die Änderungen des Pull-Requests in einer Vorschauversion Ihrer App ansehen und testen können.

Die Vorschau-URL wird mit Änderungen aus jedem Commit aktualisiert, indem automatisch im zugehörigen Vorschaukanal bereitgestellt wird. Die URL ändert sich nicht mit jedem neuen Commit.
(Optional) Stellt den aktuellen Status Ihres GitHub-Repositorys in Ihrem Live-Channel bereit, wenn der Pull-Request zusammengeführt wird.
Hinweis: Wenn Sie Vorschau-URLs verwenden, interagiert Ihre App mit den echten Backend-Ressourcen Ihres Firebase-Projekts.
GitHub-Aktion für die Bereitstellung in Firebase Hosting einrichten
Erstellen Sie ein GitHub-Repository (öffentlich oder privat) oder verwenden Sie ein vorhandenes. Sie benötigen Administratorberechtigungen für das Repository.
Richten Sie Firebase Hosting in einer lokalen Version Ihres Repositorys mit dem Befehl firebase init
ein.
Wenn Sie Hosting NICHT eingerichtet haben, führen Sie diese Version des Befehls im Stammverzeichnis Ihres lokalen Verzeichnisses aus:
firebase init hosting
Wenn Sie Hosting BEREITS eingerichtet haben, müssen Sie nur den GitHub Actions-Teil von Hosting einrichten. Führen Sie diese Version des Befehls im Stammverzeichnis Ihres lokalen Verzeichnisses aus:
firebase init hosting:github
Folgen Sie den CLI-Aufforderungen. Das Einrichten der GitHub-Aktion wird automatisch vom Befehl übernommen:
Erstellt ein Dienstkonto in Ihrem Firebase-Projekt mit der Berechtigung, in Firebase Hosting bereitzustellen.
Verschlüsselt den JSON-Schlüssel des Dienstkontos und lädt ihn als GitHub-Secret in das angegebene GitHub-Repository hoch.
Schreibt GitHub-Workflow-Konfigurationsdateien yaml
, die auf das neu erstellte Secret verweisen. Mit diesen Dateien wird die GitHub-Aktion für die Bereitstellung in Firebase Hosting konfiguriert.
Erstellen Sie in GitHub einen neuen Branch und committen Sie die Workflow-yaml
-Dateien, die von der CLI erstellt wurden.
Veröffentlichen Sie den Branch in Ihrem GitHub-Repository.
Zweig zusammenführen
Geschafft! Jede nachfolgende Pull-Anfrage in diesem GitHub-Repository erhält automatisch eine eigene „Vorschau-URL“.
Weitere Informationen zur GitHub-Aktion
Sofern nicht anders angegeben, sind die Inhalte dieser Seite unter der Creative Commons Attribution 4.0 License und Codebeispiele unter der Apache 2.0 License lizenziert. Weitere Informationen finden Sie in den Websiterichtlinien von Google Developers. Java ist eine eingetragene Marke von Oracle und/oder seinen Partnern.
Zuletzt aktualisiert: 2025-08-08 (UTC).
[null,null,["Zuletzt aktualisiert: 2025-08-08 (UTC)."],[],[],null,["# Deploy to live & preview channels via GitHub pull requests\n\n\u003cbr /\u003e\n\nYou can integrate deploys to Firebase Hosting via a GitHub Action. Here's\nwhat this GitHub Action can do for you:\n\n- Creates a new preview channel (and its associated preview URL) for every PR on\n your GitHub repository.\n\n- Adds a comment to the PR with the preview URL\n so that you and each reviewer can view and test the PR's changes in a\n \"preview\" version of your app.\n\n- Updates the preview URL with changes from each commit by automatically\n deploying to the associated preview channel. The URL doesn't change with each\n new commit.\n\n- *(Optional)* Deploys the current state of your GitHub repo to your live\n channel when the PR is merged.\n\nReminder: When using preview URLs, your app interacts with the *real* backend\nresources of your Firebase project.\n\nSet up the GitHub Action to deploy to Firebase Hosting\n------------------------------------------------------\n\n1. Create a GitHub repository (public or private) or use an existing one. You\n must have admin permissions for the repository.\n\n2. In a local version of your repo, set up Firebase Hosting using the\n [`firebase init` command](/docs/hosting/quickstart#initialize).\n\n - If you've NOT set up Hosting, run this version of the command\n from the root of your local directory:\n\n ```\n firebase init hosting\n ```\n - If you've ALREADY set up Hosting, then you just need to set up the\n GitHub Action part of Hosting. Run this version of the command from\n the root of your local directory:\n\n ```\n firebase init hosting:github\n ```\n3. Follow the CLI prompts, and the command will automatically take care of\n setting up the GitHub Action:\n\n - Creates a service account in your Firebase project with permission to\n deploy to Firebase Hosting.\n\n - Encrypts that service account's JSON key and uploads it to the specified\n GitHub repository as a\n [GitHub secret](//docs.github.com/en/free-pro-team@latest/actions/reference/encrypted-secrets).\n\n - Writes GitHub workflow `yaml` configuration files that reference the\n newly created secret. These files configure the GitHub Action to deploy to\n Firebase Hosting.\n\n4. In GitHub, create a new branch and commit the workflow `yaml` files created\n by the CLI.\n\n5. Publish the branch to your GitHub repository.\n\n6. Merge the branch.\n\nThat's it! Any subsequent PR in this GitHub repo will automatically get its own\n\"preview URL\"!\n\nLearn more about the GitHub Action\n----------------------------------\n\n- Firebase maintains the \"Deploy to Firebase Hosting\" GitHub Action as an\n open-source project.\n [View the source code.](//github.com/marketplace/actions/deploy-to-firebase-hosting)\n\n- The \"Deploy to Firebase Hosting\" GitHub Action allows for further\n configuration, like customizing the expiry date for a preview channel or\n setting a non-live channel to deploy to when a PR is merged.\n [Learn about the available configuration options.](//github.com/marketplace/actions/deploy-to-firebase-hosting#options)\n\n- Learn more about\n [GitHub Actions](//docs.github.com/en/free-pro-team@latest/actions),\n in general."]]