Deploying with GitHub Actions
Automate build, test, and SSH deployment steps in a GitHub Actions workflow.
What is GitHub Actions?
GitHub Actions is a CI/CD platform built into GitHub. Workflows defined in .github/workflows/*.yml automatically run on push, pull request, or schedule events.
Basic Workflow Structure
A workflow consists of one or more jobs, each with steps.
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: "8.3"
- name: Install dependencies
run: composer install --no-dev --optimize-autoloader
- name: Run tests
run: vendor/bin/phpunitAll lessons in this course
- Nginx and PHP-FPM Configuration
- Environment Variables and .env Files
- Deploying with GitHub Actions
- Dockerizing a PHP Application