Wdróż w celu życia podgląd kanałów za pomocą żądań pull GitHub
Zadbaj o dobrą organizację dzięki kolekcji
Zapisuj i kategoryzuj treści zgodnie ze swoimi preferencjami.
Wdrożenia możesz zintegrować z Firebase Hosting za pomocą działania GitHub. Oto, co może zrobić dla Ciebie ta akcja GitHub:
Tworzy nowy kanał podglądu (i powiązany z nim URL podglądu) dla każdego żądania scalenia w repozytorium GitHub.
Dodaje do żądania pull request komentarz z adresem URL podglądu, aby Ty i każdy recenzent mogli wyświetlić i przetestować zmiany w żądaniu pull request w „wersji podglądowej” aplikacji.

Aktualizuje URL podglądu o zmiany z każdego zatwierdzenia, automatycznie wdrażając je na powiązanym kanale podglądu. Adres URL nie zmienia się z każdym nowym zatwierdzeniem.
(Opcjonalnie) Wdraża bieżący stan repozytorium GitHub na kanale na żywo po scaleniu żądania pull.
Przypomnienie: podczas korzystania z adresów URL podglądu aplikacja wchodzi w interakcję z prawdziwymi zasobami backendu projektu Firebase.
Skonfiguruj działanie GitHub do wdrażania w Firebase Hosting
Utwórz repozytorium GitHub (publiczne lub prywatne) albo użyj istniejącego. Musisz mieć uprawnienia administratora repozytorium.
W lokalnej wersji repozytorium skonfiguruj Firebase Hosting za pomocą polecenia firebase init
.
Jeśli NIE masz skonfigurowanego Hosting, uruchom tę wersję polecenia
w katalogu głównym lokalnego katalogu:
firebase init hosting
Jeśli Hosting jest JUŻ skonfigurowany, musisz tylko skonfigurować część Hosting dotyczącą działania GitHub. Uruchom tę wersję polecenia w katalogu głównym lokalnego katalogu:
firebase init hosting:github
Postępuj zgodnie z instrukcjami w interfejsie wiersza poleceń. Polecenie automatycznie skonfiguruje działanie GitHub:
Tworzy konto usługi w projekcie Firebase z uprawnieniami do wdrażania w Firebase Hosting.
Szyfruje klucz JSON konta usługi i przesyła go do określonego repozytorium GitHub jako tajny obiekt GitHub.
Zapisuje pliki konfiguracji przepływu pracy GitHub yaml
, które odwołują się do nowo utworzonego obiektu tajnego. Te pliki konfigurują działanie GitHub do wdrażania w Firebase Hosting.
W GitHubie utwórz nową gałąź i zatwierdź pliki przepływu pracy yaml
utworzone przez interfejs wiersza poleceń.
Opublikuj gałąź w swoim repozytorium GitHub.
Scal gałąź.
To wszystko. Każde kolejne żądanie scalenia w tym repozytorium GitHub automatycznie otrzyma własny „adres URL podglądu”.
Więcej informacji o działaniu GitHub
O ile nie stwierdzono inaczej, treść tej strony jest objęta licencją Creative Commons – uznanie autorstwa 4.0, a fragmenty kodu są dostępne na licencji Apache 2.0. Szczegółowe informacje na ten temat zawierają zasady dotyczące witryny Google Developers. Java jest zastrzeżonym znakiem towarowym firmy Oracle i jej podmiotów stowarzyszonych.
Ostatnia aktualizacja: 2025-08-08 UTC.
[null,null,["Ostatnia aktualizacja: 2025-08-08 UTC."],[],[],null,["\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\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- 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."]]