Skip to content

Deploy to playground.wordpress.net #622

Deploy to playground.wordpress.net

Deploy to playground.wordpress.net #622

Workflow file for this run

name: Deploy to playground.wordpress.net
on:
workflow_dispatch:
# Deploy the website every day at 9am and 6pm UTC
schedule:
- cron: '0 9,18 * * *'
concurrency:
group: website-deployment
# TODO: Enable cancel-in-progress once we are deploying per commit?
#cancel-in-progress: true
jobs:
build_and_deploy:
# Only run this workflow from the trunk branch and when it's triggered by another workflow OR dmsnell OR adamziel
if: >
github.ref == 'refs/heads/trunk' && (
github.event_name == 'workflow_run' ||
github.event_name == 'workflow_dispatch' ||
github.actor == 'adamziel' ||
github.actor == 'dmsnell' ||
github.actor == 'bgrgicak' ||
github.actor == 'brandonpayton'
)
# Specify runner + deployment step
runs-on: ubuntu-latest
environment:
name: playground-wordpress-net-wp-cloud
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions/prepare-playground
- run: npm run build
- name: Deploy to playground.wordpress.net
shell: bash
run: |
mkdir -p ~/.ssh
echo "${{ secrets.DEPLOY_WEBSITE_TARGET_HOST_KEY }}" >> ~/.ssh/known_hosts
echo "${{ secrets.DEPLOY_WEBSITE_PRIVATE_KEY }}" > ~/.ssh/id_ed25519
chmod 0600 ~/.ssh/*
# Website files
rsync -avz -e "ssh -i ~/.ssh/id_ed25519" --delete \
dist/packages/playground/wasm-wordpress-net/ \
${{ secrets.DEPLOY_WEBSITE_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/updated-playground-files'
# Host-specific deployment scripts and server config
rsync -avz -e "ssh -i ~/.ssh/id_ed25519" --delete \
packages/playground/website-deployment/ \
${{ secrets.DEPLOY_WEBSITE_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/website-deployment'
# Copy MIME types for use with PHP-served files
scp -i ~/.ssh/id_ed25519 \
packages/php-wasm/universal/src/lib/mime-types.json \
${{ secrets.DEPLOY_WEBSITE_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/website-deployment/'
# Apply update
ssh -i ~/.ssh/id_ed25519 \
${{ secrets.DEPLOY_WEBSITE_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }} \
-tt -C '~/website-deployment/apply-update.sh'