Set up CI/CD
Current github repo already has YAML
files for prepping the code for shipping, and for deployment (via SSH) onto a development server. https://github.com/level73/stackspin-theme/actions
Copied over for simplicity:
codeshipper.yml
name: Codeshipper
on:
push:
branches:
# Run only on pushes to main
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v1
with:
node-version: 12.x
- name: Install dependencies
run: npm install
- name: Run build step
run: npm run build
- name: Commit changes
uses: EndBug/add-and-commit@v5
with:
message: "[Automated] Update build files"
add: "style* assets/css"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
deploy:
needs: 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:
- name: Deploy
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USER}}
script: |
cd ${{secrets.DESTINATION_DIR}}
git pull
echo "Deployed"
deploy.yml
# Deploy to Server on Push (branch: main)
name: Deploy
on:
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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 "deploy"
deploy:
# 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:
- name: Deploy
uses: appleboy/ssh-action@v0.1.2
with:
host: ${{secrets.SSH_HOST}}
key: ${{secrets.SSH_KEY}}
username: ${{secrets.SSH_USER}}
script: |
cd /var/www/stackspin.lvl73.it/wordpress/wp-content/themes/stackspin-theme
git pull
echo "Deployed"