Deploy to playground.wordpress.net #1036
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 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@v4 | |
with: | |
submodules: true | |
- uses: ./.github/actions/prepare-playground | |
- run: npm run build | |
- run: tar -czf wasm-wordpress-net.tar.gz dist/packages/playground/wasm-wordpress-net | |
# Store dist/packages/artifacts/wasm-wordpress-net as a build artifact | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: playground-website | |
path: wasm-wordpress-net.tar.gz | |
# The artifact only becomes available after this workflow wraps up, so let's wrap. | |
# This artifact enables the download of a pre-built package and hosting of one's own playground instance. | |
- 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' |