Skip to content

Commit

Permalink
Create deploy.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
code-boss authored Dec 4, 2024
1 parent c325b37 commit d6ddf4e
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: Deploy WordPress Plugin

env:
PHP_VERSION: '8.1'
NODE_VERSION: '16'
PLUGIN_NAME: 'wp-job-openings'

on:
push:
branches:
- staging

jobs:
build-and-deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ env.PHP_VERSION }}

- name: Cache Composer packages
uses: actions/cache@v3
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Install NPM Dependencies
run: npm ci

- name: Install Composer Dependencies
if: hashFiles('composer.json')
run: composer install --no-dev --optimize-autoloader

- name: Build Assets
run: npm run build

- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: unnecessary

- name: Adding Known Hosts
run: ssh-keyscan -p 22 -H ${{ secrets.REMOTE_HOST }} >> ~/.ssh/known_hosts

- name: Deploy with rsync
run: rsync -avz -e "ssh -p 22" --exclude='.git' --exclude='.github' --exclude='node_modules' --exclude='.gitignore' --exclude='.eslintrc' --exclude='gulpfile.js' --exclude='package.json' --exclude='package-lock.json' --exclude='composer.json' --exclude='composer.lock' --exclude='.eslintignore' --exclude='.browserslistrc' . ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:${{ secrets.REMOTE_PATH }}/wp-content/plugins/${{ env.PLUGIN_NAME }}

0 comments on commit d6ddf4e

Please sign in to comment.