Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify website deployment workflows #1404

Merged
merged 6 commits into from
May 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ensures that only one website deployment workflow can run at a time.

# TODO: Enable cancel-in-progress once we are deploying per commit?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd let it finish – stopping the deployment halfway through or when the apply-update.sh is running sounds like trouble. If we push 5 commits in rapid progression, though, perhaps this could only run for the first and the fifth, but not for anything in between?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd let it finish – stopping the deployment halfway through or when the apply-update.sh is running sounds like trouble.

Good point.

If we push 5 commits in rapid progression, though, perhaps this could only run for the first and the fifth, but not for anything in between?

That's my understanding: There can be one workflow instance active and one pending. If another becomes pending, it replaces the previous pending workflow.

#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.

Loading