Skip to content
Merged
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
31 changes: 18 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ jobs:
# Release events always map to production; workflow_dispatch uses
# the user-selected environment.
ENVIRONMENT: ${{ github.event_name == 'release' && 'production' || inputs.environment }}
# Unique suffix for every /tmp tarball on the VPS so parallel
# prod + staging deploys can't overwrite each other's bundles
# (concurrency group is keyed per-environment, so this matters).
# github.run_id is monotonic and unique per workflow run.
BUNDLE_TAG: ${{ github.run_id }}

steps:
- name: Checkout code
Expand Down Expand Up @@ -143,7 +148,7 @@ jobs:
run: |
cp -r .next/static .next/standalone/.next/static
cp -r public .next/standalone/public
tar -czf /tmp/nextjs-bundle.tar.gz -C .next/standalone .
tar -czf /tmp/nextjs-bundle-${BUNDLE_TAG}.tar.gz -C .next/standalone .

# cdcf-mcp ships the MCP adapter as a runtime Composer dependency, so its
# vendor/ must be installed (from the committed lock) before bundling.
Expand All @@ -158,13 +163,13 @@ jobs:
- name: Prepare WP theme and plugin bundles
if: env.ENVIRONMENT == 'production'
run: |
tar -czf /tmp/wp-theme.tar.gz -C wordpress/themes/cdcf-headless .
tar -czf /tmp/wp-plugin-redis-translations.tar.gz -C wordpress/plugins/cdcf-redis-translations .
tar -czf /tmp/wp-theme-${BUNDLE_TAG}.tar.gz -C wordpress/themes/cdcf-headless .
tar -czf /tmp/wp-plugin-redis-translations-${BUNDLE_TAG}.tar.gz -C wordpress/plugins/cdcf-redis-translations .
# Install cdcf-mcp's runtime deps (the MCP adapter) from the lock and
# bundle them; the plugin is non-functional without vendor/.
composer install --no-dev --no-interaction --no-progress \
--working-dir=wordpress/plugins/cdcf-mcp
tar -czf /tmp/wp-plugin-cdcf-mcp.tar.gz -C wordpress/plugins/cdcf-mcp .
tar -czf /tmp/wp-plugin-cdcf-mcp-${BUNDLE_TAG}.tar.gz -C wordpress/plugins/cdcf-mcp .

- name: Setup SSH key
env:
Expand Down Expand Up @@ -258,8 +263,8 @@ jobs:
echo "Upload attempt $attempt..."
if scp -i ~/.ssh/deploy_key \
-o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=2 \
/tmp/nextjs-bundle.tar.gz \
"${VPS_USERNAME}@${VPS_HOST}:/tmp/nextjs-bundle.tar.gz"; then
/tmp/nextjs-bundle-${BUNDLE_TAG}.tar.gz \
"${VPS_USERNAME}@${VPS_HOST}:/tmp/nextjs-bundle-${BUNDLE_TAG}.tar.gz"; then
echo "Upload succeeded on attempt $attempt"
exit 0
fi
Expand All @@ -279,7 +284,7 @@ jobs:
echo "Upload attempt $attempt..."
if scp -i ~/.ssh/deploy_key \
-o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=2 \
/tmp/wp-theme.tar.gz /tmp/wp-plugin-redis-translations.tar.gz /tmp/wp-plugin-cdcf-mcp.tar.gz \
/tmp/wp-theme-${BUNDLE_TAG}.tar.gz /tmp/wp-plugin-redis-translations-${BUNDLE_TAG}.tar.gz /tmp/wp-plugin-cdcf-mcp-${BUNDLE_TAG}.tar.gz \
"${VPS_USERNAME}@${VPS_HOST}:/tmp/"; then
echo "Upload succeeded on attempt $attempt"
exit 0
Expand All @@ -303,10 +308,10 @@ jobs:
-o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=2 \
"${VPS_USERNAME}@${VPS_HOST}" \
"mkdir -p \"$APP_DIR\" && \
tar -xzf /tmp/nextjs-bundle.tar.gz -C \"$APP_DIR\" && \
tar -xzf /tmp/nextjs-bundle-${BUNDLE_TAG}.tar.gz -C \"$APP_DIR\" && \
mkdir -p \"$APP_DIR/tmp\" && \
touch \"$APP_DIR/tmp/restart.txt\" && \
rm /tmp/nextjs-bundle.tar.gz"; then
rm /tmp/nextjs-bundle-${BUNDLE_TAG}.tar.gz"; then
echo "SSH succeeded on attempt $attempt"
exit 0
fi
Expand Down Expand Up @@ -387,12 +392,12 @@ jobs:
-o ConnectTimeout=10 -o ServerAliveInterval=15 -o ServerAliveCountMax=2 \
"${VPS_USERNAME}@${VPS_HOST}" \
"mkdir -p \"$WP_THEME_DIR\" && \
tar -xzf /tmp/wp-theme.tar.gz -C \"$WP_THEME_DIR\" && \
tar -xzf /tmp/wp-theme-${BUNDLE_TAG}.tar.gz -C \"$WP_THEME_DIR\" && \
mkdir -p \"$WP_PLUGINS_DIR/cdcf-redis-translations\" && \
tar -xzf /tmp/wp-plugin-redis-translations.tar.gz -C \"$WP_PLUGINS_DIR/cdcf-redis-translations\" && \
tar -xzf /tmp/wp-plugin-redis-translations-${BUNDLE_TAG}.tar.gz -C \"$WP_PLUGINS_DIR/cdcf-redis-translations\" && \
mkdir -p \"$WP_PLUGINS_DIR/cdcf-mcp\" && \
tar -xzf /tmp/wp-plugin-cdcf-mcp.tar.gz -C \"$WP_PLUGINS_DIR/cdcf-mcp\" && \
rm /tmp/wp-theme.tar.gz /tmp/wp-plugin-redis-translations.tar.gz /tmp/wp-plugin-cdcf-mcp.tar.gz"; then
tar -xzf /tmp/wp-plugin-cdcf-mcp-${BUNDLE_TAG}.tar.gz -C \"$WP_PLUGINS_DIR/cdcf-mcp\" && \
rm /tmp/wp-theme-${BUNDLE_TAG}.tar.gz /tmp/wp-plugin-redis-translations-${BUNDLE_TAG}.tar.gz /tmp/wp-plugin-cdcf-mcp-${BUNDLE_TAG}.tar.gz"; then
echo "SSH succeeded on attempt $attempt"
exit 0
fi
Expand Down