ทำให้ใช้งานได้ในการถ่ายทอดสด & ดูตัวอย่างแชแนลผ่านคำขอดึง GitHub
จัดทุกอย่างให้เป็นระเบียบอยู่เสมอด้วยคอลเล็กชัน
บันทึกและจัดหมวดหมู่เนื้อหาตามค่ากำหนดของคุณ
คุณสามารถผสานรวมการติดตั้งใช้งานกับ Firebase Hosting ผ่าน GitHub Action ได้ GitHub Actions นี้ช่วยคุณทำสิ่งต่อไปนี้ได้
สร้างแชแนลตัวอย่างใหม่ (และ URL ตัวอย่างที่เชื่อมโยง) สำหรับ PR ทุกรายการใน
ที่เก็บ GitHub
เพิ่มความคิดเห็นใน PR พร้อม URL ตัวอย่าง
เพื่อให้คุณและผู้ตรวจสอบแต่ละคนดูและทดสอบการเปลี่ยนแปลงของ PR ใน
แอปเวอร์ชัน "ตัวอย่าง" ได้

อัปเดต URL ตัวอย่างด้วยการเปลี่ยนแปลงจากแต่ละคอมมิตโดยการ
ติดตั้งใช้งานไปยังแชแนลตัวอย่างที่เชื่อมโยงโดยอัตโนมัติ URL จะไม่เปลี่ยนแปลงตาม
การคอมมิตใหม่แต่ละครั้ง
(ไม่บังคับ) จะทำให้สถานะปัจจุบันของที่เก็บ GitHub ไปยังช่องที่ใช้งานอยู่
เมื่อผสานรวมคำขอพุล
การแจ้งเตือน: เมื่อใช้ URL ตัวอย่าง แอปจะโต้ตอบกับทรัพยากรแบ็กเอนด์จริงของโปรเจ็กต์ Firebase
ตั้งค่า GitHub Action เพื่อติดตั้งใช้งานใน Firebase Hosting
สร้างที่เก็บ GitHub (สาธารณะหรือส่วนตัว) หรือใช้ที่เก็บที่มีอยู่ คุณต้องมีสิทธิ์ระดับผู้ดูแลระบบสำหรับที่เก็บ
ในเวอร์ชันโลคัลของที่เก็บ ให้ตั้งค่า Firebase Hosting โดยใช้คำสั่ง firebase init
หากคุณไม่ได้ตั้งค่า Hosting ให้เรียกใช้คำสั่งเวอร์ชันนี้
จากรูทของไดเรกทอรีในเครื่อง
firebase init hosting
หากตั้งค่า Hosting ไว้แล้ว คุณเพียงแค่ต้องตั้งค่าส่วน GitHub Action ของ Hosting เรียกใช้คำสั่งเวอร์ชันนี้จากรูทของไดเรกทอรีในเครื่อง
firebase init hosting:github
ทำตามข้อความแจ้งของ CLI แล้วคำสั่งจะจัดการ
การตั้งค่า GitHub Actions โดยอัตโนมัติ
สร้างบัญชีบริการในโปรเจ็กต์ Firebase ที่มีสิทธิ์ในการ
ติดตั้งใช้งานไปยัง Firebase Hosting
เข้ารหัสคีย์ JSON ของบัญชีบริการนั้นและอัปโหลดไปยัง
ที่เก็บ GitHub ที่ระบุเป็นข้อมูลลับ GitHub
เขียนไฟล์การกำหนดค่าเวิร์กโฟลว์ GitHub yaml
ที่อ้างอิงถึง
ข้อมูลลับที่สร้างขึ้นใหม่ ไฟล์เหล่านี้กำหนดค่า GitHub Action เพื่อทำให้ใช้งานได้ใน
Firebase Hosting
ใน GitHub ให้สร้างกิ่งใหม่และคอมมิตไฟล์เวิร์กโฟลว์ yaml
ที่สร้างโดย CLI
เผยแพร่กิ่งไปยังที่เก็บ GitHub
ผสานสาขา
เพียงเท่านี้ก็เสร็จแล้ว! PR ใดๆ ที่ตามมาในที่เก็บ GitHub นี้จะได้รับ "URL ตัวอย่าง" ของตัวเองโดยอัตโนมัติ
ดูข้อมูลเพิ่มเติมเกี่ยวกับ GitHub Action
Firebase ดูแลรักษา GitHub Action "Deploy to Firebase Hosting" ในฐานะโปรเจ็กต์โอเพนซอร์ส
ดูซอร์สโค้ด
GitHub Action "Deploy to Firebase Hosting" ช่วยให้กำหนดค่าเพิ่มเติมได้ เช่น การปรับแต่งวันที่หมดอายุสำหรับช่องตัวอย่างหรือการตั้งค่าช่องที่ไม่ใช่ช่องถ่ายทอดสดให้ทำการติดตั้งใช้งานเมื่อผสาน PR
ดูข้อมูลเกี่ยวกับตัวเลือกการกำหนดค่าที่มี
ดูข้อมูลเพิ่มเติมเกี่ยวกับ
GitHub Actions
โดยทั่วไป
เนื้อหาของหน้าเว็บนี้ได้รับอนุญาตภายใต้ใบอนุญาตที่ต้องระบุที่มาของครีเอทีฟคอมมอนส์ 4.0 และตัวอย่างโค้ดได้รับอนุญาตภายใต้ใบอนุญาต Apache 2.0 เว้นแต่จะระบุไว้เป็นอย่างอื่น โปรดดูรายละเอียดที่นโยบายเว็บไซต์ Google Developers Java เป็นเครื่องหมายการค้าจดทะเบียนของ Oracle และ/หรือบริษัทในเครือ
อัปเดตล่าสุด 2025-08-08 UTC
[null,null,["อัปเดตล่าสุด 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."]]