Skip to content

Commit

Permalink
Fix CORS proxy deploy workflow (#2049)
Browse files Browse the repository at this point in the history
## Motivation for the change, related issues

The CORS proxy deploy workflow isn't able to find the files it checked
out in order to sync them to the dedicated proxy site.

## Implementation details

This PR fixes multiple incorrect paths, tightens command line params,
and restores some missing bash var declarations in order to fix
deployment of the dedicated CORS proxy.

## Testing Instructions (or ideally a Blueprint)

Allow dispatching this branch's version of the workflow and trigger the
workflow manually to test.
  • Loading branch information
brandonpayton authored Dec 4, 2024
1 parent 51db66a commit faea1ee
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
14 changes: 11 additions & 3 deletions .github/workflows/deploy-cors-proxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,16 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: packages/playground/php-cors-proxy
sparse-checkout: |
packages/playground/php-cors-proxy
packages/playground/php-cors-proxy-deployment
sparse-checkout-cone-mode: false

- name: Observe working directory contents
shell: bash
run: |
pwd
ls -laR
- name: Deploy to CORS proxy server
shell: bash
Expand All @@ -43,8 +51,8 @@ jobs:
# CORS proxy files
rsync --verbose --archive --compress -e "ssh -i ~/.ssh/id_ed25519" \
--include '*/' --include '*.php' --exclude '*' \
--delete --prune-empty-dirs \
--exclude 'tests/' --include '*/' --include '*.php' --exclude '*' \
--delete --delete-excluded --prune-empty-dirs \
packages/playground/php-cors-proxy/ \
${{ secrets.DEPLOY_CORS_PROXY_TARGET_USER }}@${{ secrets.DEPLOY_WEBSITE_TARGET_HOST }}:'~/updated-proxy-files'
Expand Down
10 changes: 9 additions & 1 deletion packages/playground/php-cors-proxy-deployment/apply-update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

set -euo pipefail

# Explicitly use the site's declared PHP version.
# Otherwise, we've seen this defaulting to older versions which can break our scripts.
SITE_PHP="/usr/local/php${PHP_VERSION}/bin/php"
SITE_API_BASE="$( "$SITE_PHP" -r 'require "/scripts/env.php"; echo SITE_API_BASE;')"

echo Adding config file to updated proxy files
cp ~/cors-proxy-deployment/cors-proxy-config.php ~/updated-proxy-files/

echo Syncing staged files to production
rsync -av --delete --no-perms --omit-dir-times ~/updated-proxy-files/ /srv/htdocs/

Expand All @@ -14,6 +22,6 @@ curl -sS -X POST -H "Auth: $ATOMIC_SITE_API_KEY" "$SITE_API_BASE/edge-cache/$ATO
echo Applying latest CORS proxy rate-limiting schema
# NOTE: This will reset rate-limiting token buckets, but that should be tolerable
# as long as we're generally discouraging abuse of the proxy.
cat ~/website-deployment/cors-proxy-rate-limiting-table.sql | mysql --database="$DB_NAME"
cat ~/cors-proxy-deployment/cors-proxy-rate-limiting-table.sql | mysql --database="$DB_NAME"

echo Done!

0 comments on commit faea1ee

Please sign in to comment.