Skip to content

Instantly share code, notes, and snippets.

@kagg-design
Created November 16, 2022 16:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kagg-design/5ab87fba2d9e5b5d53bba2b7454aa3e3 to your computer and use it in GitHub Desktop.
Save kagg-design/5ab87fba2d9e5b5d53bba2b7454aa3e3 to your computer and use it in GitHub Desktop.
GitHub action to deploy the plugin to the staging environment on commit to master
name: Deploy to Stage
on:
push:
branches:
- master
jobs:
release:
name: Deploy to Stage
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Get Composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Set up Composer caching
uses: actions/cache@v3
env:
cache-name: cache-composer-dependencies
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Install dependencies in prod version
run: |
composer config github-oauth.github.com ${{ secrets.GITHUB_TOKEN }}
composer install --no-dev
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build js app
run: |
yarn
yarn run build:prod
- name: Deploy the code
uses: burnett01/rsync-deployments@5.2
with:
switches: -cvzr --delete --exclude-from=.distignore --chmod=D775,F664
path: ${{ env.GITHUB_WORKSPACE }}
remote_path: /var/www/xxx/wp-content/plugins/yyyyy/
remote_host: xxx.xxx.xxx.xxx
remote_user: yyyyy
remote_key: ${{ secrets.DEPLOY_KEY }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment