update theme version, cache bust #56
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
# Experimental workflow to test GitHub Actions. | |
name: Deploy | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
deploy: | |
name: Deploy to Production | |
runs-on: ubuntu-20.04 | |
environment: | |
name: production | |
url: https://purpleturtlecreative.com/ | |
steps: | |
# Download all source code. | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
with: | |
submodules: recursive | |
token: ${{ secrets.PTC_GITHUB_PAT }} | |
# Get submodule SHAs for build caching. | |
- name: Get Submodule SHAs | |
id: submodule-shas | |
run: | | |
echo "SHA_PTC_THEME=$( git submodule status wp-content/themes/purple-turtle-creative | awk '{print $1}' )" >> "$GITHUB_OUTPUT" | |
echo "SHA_COMPLETIONIST_PRO=$( git submodule status wp-content/plugins/completionist-pro | awk '{print $1}' )" >> "$GITHUB_OUTPUT" | |
# Build the Purple Turtle Creative theme. | |
- name: WordPress Theme - Cache | |
id: ptc-theme-cache | |
uses: actions/cache@v3 | |
with: | |
path: wp-content/themes/purple-turtle-creative | |
key: ptc-theme-${{ steps.submodule-shas.outputs.SHA_PTC_THEME }} | |
- name: WordPress Theme - Build | |
if: ${{ steps.ptc-theme-cache.outputs.cache-hit != 'true' }} | |
working-directory: wp-content/themes/purple-turtle-creative | |
run: | | |
./build_install.sh | |
./build_cleanup.sh | |
# Build the Completionist Pro plugin. | |
- name: Completionist Pro - Cache | |
id: completionist-pro-cache | |
uses: actions/cache@v3 | |
with: | |
path: wp-content/plugins/completionist-pro | |
key: completionist-pro-${{ steps.submodule-shas.outputs.SHA_COMPLETIONIST_PRO }} | |
- name: Completionist Pro - Build | |
if: ${{ steps.completionist-pro-cache.outputs.cache-hit != 'true' }} | |
working-directory: wp-content/plugins/completionist-pro | |
run: | | |
./build_install.sh | |
./build_cleanup.sh | |
# Remove unnecessary files and directories. | |
- name: Final Clean Up | |
run: | | |
find . -name '.git*' -exec rm -rf {} + -depth | |
find . -type d -empty -delete | |
# Upload Code to Production. | |
- name: Sync Code to Production | |
env: | |
remote: "github@${{ secrets.PTC_PROD_HOSTNAME }}" | |
destination: "/var/www/html" | |
run: | | |
echo "${{ secrets.PTC_GITHUB_SSH_KEY }}" > deploy_key | |
chmod 600 ./deploy_key | |
rsync --recursive --links --checksum --delete \ | |
--exclude-from="./exclude.lst" \ | |
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \ | |
./wp-content ${{ env.remote }}:${{ env.destination }} | |
ssh -i ./deploy_key -o StrictHostKeyChecking=no ${{ env.remote }} 'chmod -R 775 ${{ env.destination }}/wp-content; chgrp -R www-data ${{ env.destination }}/wp-content' || true |