Skip to content

Commit

Permalink
Simplify website deployment workflows (#1404)
Browse files Browse the repository at this point in the history
Now that we are pushing built website files directly to WP Cloud, there
is no longer any need to run deployment as a two-workflow process. It
means we can just push the build directly rather than having to save it
as a build artifact that is downloaded by the next workflow.

## How is the problem addressed?

This PR merges the relevant steps from the second workflow into the
first and deletes a lot of unnecessary code.

## Testing Instructions

Test via workflow instrumentation and temporary changes to deploy to a
staging site:
https://wordpress-playground-staging.atomicsites.blog
  • Loading branch information
brandonpayton authored May 16, 2024
1 parent 1e184d8 commit e2f3285
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 100 deletions.
43 changes: 34 additions & 9 deletions .github/workflows/build-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
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
Expand All @@ -22,16 +27,36 @@ jobs:
# Specify runner + deployment step
runs-on: ubuntu-latest
environment:
name: playground-wordpress-net
name: playground-wordpress-net-wp-cloud
steps:
- uses: actions/checkout@v3
- 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@v2
with:
name: playground-website
path: wasm-wordpress-net.tar.gz
# The artifact only becomes available after this workflow wraps up, so let's wrap.
# The deploy-website.yml workflow will pick up the artifact and deploy it.

- 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'
91 changes: 0 additions & 91 deletions .github/workflows/deploy-website-next.yml

This file was deleted.

0 comments on commit e2f3285

Please sign in to comment.