Skip to content

Instantly share code, notes, and snippets.

@michelmany
Created October 5, 2021 17:48
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 michelmany/4f321aab514e3af9ecae49db64a73cf9 to your computer and use it in GitHub Desktop.
Save michelmany/4f321aab514e3af9ecae49db64a73cf9 to your computer and use it in GitHub Desktop.
WordPress Theme Deployment with Github Action and rsync
# This is a basic workflow to help you get started with Actions
name: Build & Deploy to Staging (DO)
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
push:
branches: [ staging ]
pull_request:
branches: [ staging ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
# Runs a single command using the runners shell
- uses: actions/setup-node@v2
with:
node-version: 14.17.1
- name: Install dependencies
run: yarn
- name: Build
run: yarn production
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: 'just-a-placeholder-so-we-dont-get-errors'
- name: Adding Known Hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts
- name: Deploy with rsync
run: |
rsync -avz ./ ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{secrets.SSH_DEST}} \
--exclude /.git/ \
--exclude /.github/ \
--exclude /node_modules/ \
--exclude webpack.mix.js \
--exclude yarn.lock \
--exclude /src/ \
--exclude .gitignore \
--exclude .DS_Store
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment