-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions CI/CD pipeline for deployment to Hostinger
- Loading branch information
Showing
1 changed file
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |