-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
11 additions
and
35 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 |
---|---|---|
@@ -1,52 +1,28 @@ | ||
name: Deploy WordPress Plugin | ||
env: | ||
PHP_VERSION: '8.1' | ||
NODE_VERSION: '16' | ||
PLUGIN_NAME: 'wp-job-openings' | ||
# See https://zellwk.com/blog/github-actions-deploy/ an explanation of this code | ||
name: deploy | ||
on: | ||
push: | ||
branches: | ||
- main | ||
- master | ||
workflow_dispatch: | ||
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 | ||
- uses: actions/checkout@v2 | ||
- uses: actions/setup-node@v1 | ||
|
||
- run: npm install | ||
- 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" \ | ||
./ ${{ env.REMOTE_USER }}@${{ env.REMOTE_HOST }}:${{ env.REMOTE_PATH }}/wp-content/plugins/${{ env.PLUGIN_NAME }}/ | ||
run: rsync -avz -e "ssh -p 22" . ${{ secrets.REMOTE_USER }}@${{ secrets.REMOTE_HOST }}:/home/awsmstaging/public_html/jobs/wp-content/plugins/wp/ |