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
- GitHub account
- GitHub repository containing the web app to deploy
- Accessible server over FTP
- Any standard web hosting service can be used.
Step 1 - Obtain FTP credentials and add them to GitHub
- Navigate to "Websites & Domains" in your control panel.
- Select the desired domain for hosting.
- Choose "FTP Access" under "Files & Databases".
- Click "Add an FTP Account" and fill in the necessary details.
- Note down the credentials for later use.
- Add these credentials to your GitHub repository under "Settings" > "Secrets and variables" > "Actions".
Step 2 - Configure the deployment workflow
- Go to the "Actions" tab in your GitHub repository.
- Select "Set up a workflow yourself".
- Copy and paste the following code snippet:
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
- Replace the placeholders with your actual details.
- Commit the changes with an appropriate message.
Step 3 - Verify the GitHub Action
- Push updates to your main branch to initiate the workflow.
- Monitor the "Actions" tab in your repository to see the workflow in action.
- 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.