Skip to content

Deploy Simulation Tests (dry-run) #153

Deploy Simulation Tests (dry-run)

Deploy Simulation Tests (dry-run) #153

Workflow file for this run

name: Deploy Simulation Tests (dry-run)
on:
workflow_dispatch:
schedule:
- cron: '0 4 * * *' # daily at 04:00 UTC
pull_request:
# Run when the deploy workflow itself is modified to validate safety changes
paths:
- '.github/workflows/deploy.yml'
jobs:
simulate:
name: Simulate deploy scenarios
runs-on: ubuntu-latest
strategy:
matrix:
scenario:
- { sim_ref: 'refs/tags/v1.2.3', expect_prod: 'true' }
- { sim_ref: 'refs/heads/main', expect_prod: 'false' }
- { sim_ref: 'refs/tags/notv1.0', expect_prod: 'false' }
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Simulate tag detection
id: detect
run: |
SIM_REF='${{ matrix.scenario.sim_ref }}'
echo "Simulating ref: $SIM_REF"
if echo "$SIM_REF" | grep -qE '^refs/tags/v'; then
echo "is_production=true" >> $GITHUB_OUTPUT
echo "tag_name=$(echo ${SIM_REF#refs/tags/})" >> $GITHUB_OUTPUT
else
echo "is_production=false" >> $GITHUB_OUTPUT
echo "tag_name=" >> $GITHUB_OUTPUT
fi
- name: Assert expected production flag
run: |
echo "Detected is_production=${{ steps.detect.outputs.is_production }} (expected: ${{ matrix.scenario.expect_prod }})"
if [ "${{ steps.detect.outputs.is_production }}" != "${{ matrix.scenario.expect_prod }}" ]; then
echo "Production detection did not match expected value" >&2
exit 1
fi
- name: Show simulated deploy commands (dry-run)
run: |
echo "---- DRY RUN: deploy simulation ----"
EXCLUDES="--exclude '.git' --exclude '.github' --exclude '.claude' --exclude '.vscode'"
EXCLUDES="$EXCLUDES --exclude 'tests' --exclude 'docs' --exclude 'scripts' --exclude 'logs' --exclude 'examples'"
EXCLUDES="$EXCLUDES --exclude 'venv' --exclude 'env' --exclude '__pycache__' --exclude '.pytest_cache' --exclude '.ruff_cache' --exclude '.mypy_cache'"
EXCLUDES="$EXCLUDES --exclude '.benchmarks' --exclude '.venv_smoke' --exclude '.playwright-mcp'"
EXCLUDES="$EXCLUDES --exclude 'build' --exclude 'dist' --exclude '*.egg-info' --exclude 'example_model_data'"
EXCLUDES="$EXCLUDES --exclude '/pages' --exclude '/src' --exclude '/Data'"
echo "Would rsync (dry-run): rsync -avz --delete $EXCLUDES ./ \"$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH\""
echo "Would pip install: pip install -e \$TARGET/packages/pypath && pip install -e \$TARGET/packages/pypath-shiny"
echo "Would fix ownership: sudo chown -R shiny:shiny \$TARGET"
if [ "${{ steps.detect.outputs.is_production }}" = "true" ]; then
echo "Would restart Shiny Server: ssh \"$DEPLOY_USER@$DEPLOY_HOST\" 'sudo systemctl restart shiny-server || sudo service shiny-server restart'"
else
echo "Not a production tag, no restart would be attempted."
fi
env:
DEPLOY_USER: "REDACTED_USER"
DEPLOY_HOST: "example.com"
DEPLOY_PATH: "/tmp/test"