Header Ads

Learn how to automate the deployment of your Ionic or Angular blog using GitHub Actions. Step-by-step guide for SSH and Firebase Hosting deployment.

How to Use GitHub Actions to Auto-Deploy Your Blog 

Manually uploading files every time you update your blog can be tedious and prone to errors. That’s where GitHub Actions comes in—a powerful CI/CD tool built right into GitHub that lets you automate your deployment process.

In this guide, I’ll show you how to set up GitHub Actions to automatically deploy your blog — whether it’s built with IonicAngular, or as a static site — to a live production server or hosting platform every time you push updates to the repository.


What You’ll Need

  • A blog project (Ionic, Angular, or static HTML/CSS)
  • GitHub repository
  • A deployment target (DigitalOcean, Firebase, or any server with SSH access)
  • Basic knowledge of YAML, Git, and your hosting environment


Step 1: Create a .github/workflows Folder

In your project root, create this folder:

mkdir -p .github/workflows

Inside it, create a file like deploy.yml.


Step 2: Define Your GitHub Action

Here’s an example for an Ionic or Angular blog that builds and deploys to a remote server via SSH:

name: Deploy Blog to Server


on:

  push:

    branches:

      - main


jobs:

  deploy:

    runs-on: ubuntu-latest


    steps:

      - name: Checkout code

        uses: actions/checkout@v3


      - name: Set up Node.js

        uses: actions/setup-node@v3

        with:

          node-version: 18


      - name: Install dependencies

        run: npm install


      - name: Build the project

        run: npm run build


      - name: Deploy via SCP

        uses: appleboy/scp-action@v0.1.4

        with:

          host: ${{ secrets.SERVER_HOST }}

          username: ${{ secrets.SERVER_USER }}

          key: ${{ secrets.SERVER_SSH_KEY }}

          source: "./www/"

          target: "/var/www/ionic-app"


Step 3: Add SSH Deployment Secrets

Go to your GitHub repo → SettingsSecrets and variablesActions → New repository secret.

Add the following:

Secret NameDescription
       SERVER_HOST               Your server IP or domain
       SERVER_USERThe username to SSH (e.g., root)
       SERVER_SSH_KEYYour private key (not password)

 Make sure your server’s ~/.ssh/authorized_keys contains the matching public key

Optional: Auto-deploy to Firebase Hosting

If you’re hosting a static blog on Firebase:

- name: Deploy to Firebase Hosting

  uses: w9jds/firebase-action@v12.9.0

  with:

    args: deploy --only hosting

  env:

    FIREBASE_TOKEN: ${{ secrets.FIREBASE_TOKEN }}


To get a token:

firebase login:ci

Then add it as a secret in GitHub.


Full Workflow Summary

Whenever you push to the main branch:

  • GitHub Actions installs dependencies
  • Builds your project
  • Transfers your build files to the server (or hosting platform)
  • No more manual deployment! 

Post a Comment

0 Comments