Automating Web App Deployment with GitHub

Learn how to set up a seamless continuous deployment workflow using GitHub Actions and FTP.

2023-08-14 11:58:09 - Kassem Husseine

Introduction

This guide walks you through the procedure of deploying a web application automatically via FTP with the assistance of GitHub Actions. This workflow allows for continuous deployment, where updates to your GitHub repository are automatically pushed to your FTP server.

Requirements

Step 1 - Obtain FTP credentials and add them to GitHub

  1. Navigate to "Websites & Domains" in your control panel.
  2. Select the desired domain for hosting.
  3. Choose "FTP Access" under "Files & Databases".
  4. Click "Add an FTP Account" and fill in the necessary details.
  5. Note down the credentials for later use.
  6. Add these credentials to your GitHub repository under "Settings" > "Secrets and variables" > "Actions".

Step 2 - Configure the deployment workflow


name: FTP Deployment

on:
 push:
  branches:
   - main

jobs:
 deploy:
  runs-on: ubuntu-latest

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

   - name: Deploy over FTP
    uses: SamKirkland/FTP-Deploy-Action@3.2.0
    with:
     server: YOUR_SERVER_ADDRESS
     username: ${{ secrets.FTP_USERNAME }}
     password: ${{ secrets.FTP_PASSWORD }}
     server-dir: /your/server/folder
     local-dir: ./your/local/folder

Step 3 - Verify the GitHub Action

  1. Push updates to your main branch to initiate the workflow.
  2. Monitor the "Actions" tab in your repository to see the workflow in action.
  3. Once completed, verify the changes in your control panel.

Conclusion

You have now implemented an automatic deployment process using GitHub Actions. Updates to your repository will now automatically trigger an FTP push to your server. This automation simplifies deployment, as there is no need to manually transfer files.

More Posts