DevOps for Developers: CI/CD with GitHub Actions, Firebase Hosting & Docker

DevOps for Developers CICD with GitHub Actions, Firebase Hosting & Docker

If you’re a developer looking to automate your deployment workflow, this guide will help you set up a powerful CI/CD pipeline using GitHub Actions, Firebase Hosting, and Docker. You’ll learn how to streamline your development process, reduce human error, and ship faster—without becoming a DevOps expert.

🔧 What You’ll Learn

  • Setting up GitHub Actions for CI/CD
  • Building and pushing Docker images
  • Deploying to Firebase Hosting automatically
  • Bonus: Securing secrets and optimizing builds

🚀 Why CI/CD Matters for Developers

CI/CD (Continuous Integration and Continuous Deployment) is essential for modern software teams. It ensures that every change is tested, built, and deployed automatically, making your workflow:

  • Faster: Automate build, test, and deploy.
  • Safer: Avoid manual deployment mistakes.
  • Repeatable: Set it up once, run it forever.

🛠 Prerequisites

To follow this guide, you’ll need:

  • A GitHub repository
  • A Firebase project (with Hosting enabled)
  • Docker installed locally
  • firebase-tools installed globally
  • Firebase CLI authenticated with your project

🔄 Step 1: Set Up Firebase Hosting

  1. Run firebase init hosting
  2. Choose your project and public directory (e.g., build/ or dist/)
  3. Skip setting up GitHub Actions for now—we’ll do it manually

⚙️ Step 2: Create a .github/workflows/deploy.yml

Here’s a basic workflow to deploy to Firebase Hosting after every push to main:

name: Deploy to Firebase Hosting

on:
  push:
    branches:
      - main

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v3
        with:
          node-version: '18'

      - name: Install dependencies
        run: npm install

      - name: Build
        run: npm run build

      - name: Deploy to Firebase
        uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT }}'
          channelId: live

🛡️ Security Tip: Store your Firebase service account JSON as a secret (FIREBASE_SERVICE_ACCOUNT) in the GitHub repo settings.

🐳 Step 3: Add Docker Support

To containerize your app:

Dockerfile

# Example for Node.js app
FROM node:18-alpine

WORKDIR /app
COPY . .
RUN npm install && npm run build

EXPOSE 8080
CMD ["npm", "start"]

Then update your workflow:

- name: Build Docker image
  run: docker build -t your-app-name .

- name: Push Docker image to registry
  run: echo "Pushing to DockerHub or GCR..." # add your push logic here

🔥 Pro tip: You can use GitHub Packages or Google Artifact Registry.

✅ Bonus: Add Lint & Test Steps

To make your CI flow more robust:

- name: Run Linter
  run: npm run lint

- name: Run Tests
  run: npm test

🌍 Real-World Use Cases

  • Web Apps: Deploy React, Angular, or Vue apps to Firebase Hosting
  • APIs: Containerize Node/Express or Python APIs and deploy them via Docker
  • Microservices: Manage builds and environments with GitHub Actions + Docker tags

🧠 Final Thoughts

By combining GitHub Actions, Firebase Hosting, and Docker, you create a fast, flexible, and scalable CI/CD pipeline tailored for developers. Whether you’re shipping a web app or backend service, automation gives you the power to move faster and with confidence.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top