This guide explains how to integrate GitHub Actions into your existing project for automated deployment, testing, and CI/CD processes.
- In your project's root folder, create the following path:
/.github/workflows
- Inside this folder, create a new YAML file, e.g.,
deploy.yml
.
Add the following content to your .github/workflows/deploy.yml
file:
name: π Deploy Project
on:
push:
branches:
- main # Runs on push to the `main` branch
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: π Checkout Code
uses: actions/checkout@v4
- name: π Upload via FTP
uses: SamKirkland/FTP-Deploy-Action@v4.3.5
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
server-dir: "/public_html/" # Path to deploy files on your FTP server
local-dir: "./" # Path to your project's local files
- Go to your repository on GitHub.
- Navigate to Settings β Secrets and Variables β Actions.
- Click the New repository secret button.
- Add the following secrets:
FTP_SERVER
β Your FTP server's IP or domain.FTP_USERNAME
β The username for the FTP account.FTP_PASSWORD
β The password for the FTP account.
- Commit the
.github/workflows/deploy.yml
file to your repository. - Push the changes to your remote repository.
git add .github/workflows/deploy.yml
git commit -m "Add GitHub workflow for FTP deployment"
git push origin main
- Go to your GitHub repository.
- Click the Actions tab.
- Select your workflow and view the logs for each step.
- Test your workflow in a staging environment before deploying to production.
- Use conditional checks to prevent accidental deployments (e.g., deploy only when changes are made in specific folders).
- Regularly review your workflow for outdated dependencies or security risks.
If you have questions or need custom workflow integration, feel free to ask! π