Skip to content

Commit

Permalink
Add GitHub Actions CI/CD pipeline for deployment to Hostinger
Browse files Browse the repository at this point in the history
  • Loading branch information
Wiltzsu committed Jul 12, 2024
1 parent 6bcfee7 commit a3e9438
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: PHP CI/CD Pipeline

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: Validate composer.json and composer.lock
run: composer validate

- name: Install Dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Check coding standards (placeholder)
run: echo "Run coding standards checks here"
# You can integrate tools like PHP_CodeSniffer or PHP-CS-Fixer here

deploy:
runs-on: ubuntu-latest
needs: build
if: github.ref == 'refs/heads/main' && github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.3'
tools: composer

- name: Install Dependencies
run: composer install --prefer-dist --no-progress --no-suggest

- name: Set up SSH Key and Host
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_KEY }}" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H 45.84.204.10 >> ~/.ssh/known_hosts
- name: Deploy to Hostinger
run: |
rsync -av --delete --exclude='.git*' --exclude='/node_modules' ./ [email protected]:/home/u942333698/public_html/
env:
DEPLOY_KEY: ${{ secrets.DEPLOY_KEY }}

0 comments on commit a3e9438

Please sign in to comment.