Deploy Playground website #564
This file contains hidden or 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 Playground website | |
| on: | |
| workflow_dispatch: | |
| # Deploy the website every Tuesday at 11am UTC | |
| schedule: | |
| - cron: '0 11 * * 2' | |
| concurrency: | |
| group: website-deployment | |
| jobs: | |
| build_and_deploy: | |
| # Only run this workflow from the trunk branch and when it's triggered by another workflow OR a Playground maintainer | |
| if: > | |
| github.ref == 'refs/heads/trunk' && ( | |
| github.event_name == 'workflow_run' || | |
| github.actor == 'adamziel' || | |
| github.actor == 'akirk' || | |
| github.actor == 'dmsnell' || | |
| github.actor == 'bgrgicak' || | |
| github.actor == 'brandonpayton' || | |
| github.actor == 'zaerl' || | |
| github.actor == 'janjakes' || | |
| github.actor == 'mho22' | |
| ) | |
| # Specify runner + deployment step | |
| runs-on: ubuntu-latest | |
| environment: | |
| name: playground-wordpress-net-wp-cloud | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| submodules: true | |
| # Allow deploying a specific ref for folks who want to pin a specific version. | |
| ref: ${{ vars.GIT_REF_TO_DEPLOY }} | |
| - uses: ./.github/actions/prepare-playground | |
| - run: npx nx build playground-website | |
| env: | |
| CORS_PROXY_URL: ${{ vars.CORS_PROXY_URL }} | |
| - 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 Playground website build | |
| 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' | |
| # Include MIME types for use with PHP-served files | |
| cp packages/php-wasm/universal/src/lib/mime-types.json \ | |
| packages/playground/website-deployment/ | |
| # 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' | |
| # Apply update | |
| ssh -i ~/.ssh/id_ed25519 \ | |
| ${{ secrets.DEPLOY_WEBSITE_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }} \ | |
| -tt -C '~/website-deployment/apply-update.sh' |