MOar #207
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
name: Deploy | |
on: push | |
# Env | |
env: | |
SRC: './' | |
# PROD: 'SITE@SITE.ssh.wpengine.net:/sites/SITE/wp-content/themes/SITE/' | |
# STAGE: 'STAGESITE@STAGESITE.ssh.wpengine.net:/sites/STAGESITE/wp-content/themes/SITE/' | |
jobs: | |
deploy: | |
# https://github.community/t/how-to-set-and-access-a-workflow-variable/17335/18 | |
# if: (env.STAGE && !startsWith(github.ref, 'refs/tags/v')) || (env.PROD && startsWith(github.ref, 'refs/tags/v')) | |
# NOTE: Remove this if-statement if you add a staging environment | |
if: startsWith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
# Steps | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 21.6.2 | |
# Cache NPM | |
- name: Cache NPM | |
id: npm-cache | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: npm-${{ hashFiles('package-lock.json') }} | |
# Cache Composer | |
- name: Cache Composer | |
id: composer-cache | |
uses: actions/cache@v3 | |
with: | |
path: vendor | |
key: composer-${{ hashFiles('composer.lock') }} | |
# Cache Fontello | |
- name: Cache Fontello | |
id: fontello-cache | |
uses: actions/cache@v3 | |
with: | |
path: | | |
src/sass/icons.scss | |
src/assets/fontello | |
key: fontello-${{ hashFiles('src/icons.json') }} | |
# Cache Webpack | |
- name: Cache Webpack | |
id: webpack-cache | |
uses: actions/cache@v3 | |
with: | |
path: dist | |
key: webpack-${{ hashFiles('src/**/*') }}-${{ hashFiles('modules/**/*.scss') }}-${{ hashFiles('modules/**/*.js') }}-${{ hashFiles('lang/*.po') }} | |
# NPM Install | |
- name: NPM Install | |
if: steps.npm-cache.outputs.cache-hit != 'true' | |
run: npm install | |
# Composer Install | |
- name: Composer Install | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install | |
# Fontello | |
- name: Download Fontello | |
if: steps.fontello-cache.outputs.cache-hit != 'true' | |
run: npm run fontello | |
# Webpack | |
- name: Run Webpack | |
if: steps.webpack-cache.outputs.cache-hit != 'true' | |
run: npm run build | |
# Create SSH key | |
- name: Create SSH Key | |
run: | | |
echo "${{secrets.DEPLOY_KEY}}" > deploy_key | |
chmod 600 ./deploy_key | |
# Deploy to Stage | |
- name: Deploy to Stage | |
if: env.STAGE | |
run: rsync -chav --delete -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' --exclude-from='./.prodignore' ${{env.SRC}} ${{env.STAGE}} | |
# Deploy to Prod | |
- name: Deploy to Prod | |
if: env.PROD && startsWith(github.ref, 'refs/tags/v') | |
run: rsync -chav --delete -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' --exclude-from='./.prodignore' ${{env.SRC}} ${{env.PROD}} |