|
| 1 | +# Dual Deployment Setup Guide |
| 2 | + |
| 3 | +This project supports two deployment modes: |
| 4 | + |
| 5 | +1. **Public Portfolio** (GitHub Pages + Shinylive) - No authentication |
| 6 | +2. **Private Client Access** (Shinyapps.io) - Auth0 authentication |
| 7 | + |
| 8 | +## 🔧 Setup Instructions |
| 9 | + |
| 10 | +### 1. Auth0 Configuration |
| 11 | + |
| 12 | +1. Create an Auth0 application at https://manage.auth0.com/ |
| 13 | +2. Configure your Auth0 app: |
| 14 | + - **Application Type**: Regular Web Application |
| 15 | + - **Allowed Callback URLs**: |
| 16 | + - `https://YOUR_ACCOUNT.shinyapps.io/donor-retention-private/` |
| 17 | + - `https://YOUR_ACCOUNT.shinyapps.io/board-packet-private/` |
| 18 | + - **Allowed Logout URLs**: |
| 19 | + - `https://YOUR_ACCOUNT.shinyapps.io/donor-retention-private/` |
| 20 | + - `https://YOUR_ACCOUNT.shinyapps.io/board-packet-private/` |
| 21 | + - **Allowed Web Origins**: `https://YOUR_ACCOUNT.shinyapps.io` |
| 22 | + |
| 23 | +### 2. Shinyapps.io Setup |
| 24 | + |
| 25 | +1. Create account at https://www.shinyapps.io/ |
| 26 | +2. Get your deployment tokens: |
| 27 | + - Go to Account > Tokens |
| 28 | + - Copy your account name, token, and secret |
| 29 | + |
| 30 | +### 3. GitHub Secrets Configuration |
| 31 | + |
| 32 | +Add these secrets to your GitHub repository (Settings > Secrets and variables > Actions): |
| 33 | + |
| 34 | +#### Required Secrets: |
| 35 | +``` |
| 36 | +SHINYAPPS_ACCOUNT=your-shinyapps-account-name |
| 37 | +SHINYAPPS_TOKEN=your-shinyapps-token |
| 38 | +SHINYAPPS_SECRET=your-shinyapps-secret |
| 39 | +
|
| 40 | +AUTH0_DOMAIN=your-auth0-domain.auth0.com |
| 41 | +AUTH0_CLIENT_ID=your-auth0-client-id |
| 42 | +AUTH0_CLIENT_SECRET=your-auth0-client-secret |
| 43 | +``` |
| 44 | + |
| 45 | +### 4. Local Development with Auth0 |
| 46 | + |
| 47 | +1. Copy the auth0 template: |
| 48 | + ```bash |
| 49 | + cp donor-retention-calculator/_auth0.yml.template donor-retention-calculator/_auth0.yml |
| 50 | + ``` |
| 51 | + |
| 52 | +2. Edit `_auth0.yml` with your Auth0 credentials: |
| 53 | + ```yaml |
| 54 | + name: donor-retention-local |
| 55 | + remote_url: 'http://localhost:8100/' |
| 56 | + auth0_config: |
| 57 | + api_url: https://your-domain.auth0.com |
| 58 | + credentials: |
| 59 | + key: your-client-id |
| 60 | + secret: your-client-secret |
| 61 | + ``` |
| 62 | +
|
| 63 | +3. Update Auth0 app to allow localhost: |
| 64 | + - Add `http://localhost:8100/` to Allowed Callback URLs |
| 65 | + - Add `http://localhost:8100/` to Allowed Logout URLs |
| 66 | + - Add `http://localhost:8100/` to Allowed Web Origins |
| 67 | + |
| 68 | +## 🚀 Deployment |
| 69 | + |
| 70 | +### Automatic Deployment |
| 71 | + |
| 72 | +Both deployments happen automatically: |
| 73 | + |
| 74 | +- **GitHub Pages (Public)**: Triggers on push to `main` via existing workflow |
| 75 | +- **Shinyapps.io (Private)**: Triggers on push to `main` when app files change |
| 76 | + |
| 77 | +### Manual Deployment |
| 78 | + |
| 79 | +You can manually deploy to Shinyapps.io: |
| 80 | + |
| 81 | +1. Go to Actions tab in GitHub |
| 82 | +2. Select "Deploy to Shinyapps.io" workflow |
| 83 | +3. Click "Run workflow" |
| 84 | +4. Choose which app to deploy |
| 85 | + |
| 86 | +## 🔗 Access URLs |
| 87 | + |
| 88 | +After deployment, your apps will be available at: |
| 89 | + |
| 90 | +- **Public Portfolio**: |
| 91 | + - Donor Retention: `https://yourusername.github.io/nonprofit-analytics-tools/donor-retention-calculator/` |
| 92 | + - Board Packet: `https://yourusername.github.io/nonprofit-analytics-tools/board-packet-generator/` |
| 93 | + |
| 94 | +- **Private Client Access**: |
| 95 | + - Donor Retention: `https://your-account.shinyapps.io/donor-retention-private/` |
| 96 | + - Board Packet: `https://your-account.shinyapps.io/board-packet-private/` |
| 97 | + |
| 98 | +## 🔍 How It Works |
| 99 | + |
| 100 | +The apps automatically detect their environment: |
| 101 | + |
| 102 | +- **Shinylive**: Runs in public mode (no auth) |
| 103 | +- **Shinyapps.io**: Loads Auth0 if config file present |
| 104 | +- **Local**: Uses Auth0 if `_auth0.yml` exists |
| 105 | + |
| 106 | +## 📁 File Structure |
| 107 | + |
| 108 | +``` |
| 109 | +nonprofit-analytics-tools/ |
| 110 | +├── .github/workflows/ |
| 111 | +│ ├── deploy-shinylive.yml # Public deployment |
| 112 | +│ └── deploy-shinyapps.yml # Private deployment |
| 113 | +├── donor-retention-calculator/ |
| 114 | +│ ├── app.R # Main app with conditional auth |
| 115 | +│ └── _auth0.yml.template # Auth0 config template |
| 116 | +├── board-packet-generator/ |
| 117 | +│ └── app.R # Board packet app |
| 118 | +└── DEPLOYMENT.md # This guide |
| 119 | +``` |
| 120 | +
|
| 121 | +## 🔒 Security Notes |
| 122 | +
|
| 123 | +- Auth0 config files are never committed to git |
| 124 | +- Secrets are only available during GitHub Actions |
| 125 | +- Local `_auth0.yml` should be in `.gitignore` |
| 126 | +- Private apps require Auth0 login to access |
| 127 | +
|
| 128 | +## 🐛 Troubleshooting |
| 129 | +
|
| 130 | +### App won't load on Shinyapps.io |
| 131 | +- Check that all required secrets are set |
| 132 | +- Verify Auth0 callback URLs match deployment URL |
| 133 | +- Check deployment logs in GitHub Actions |
| 134 | +
|
| 135 | +### Auth0 not working locally |
| 136 | +- Ensure `_auth0.yml` exists and has correct credentials |
| 137 | +- Verify localhost is added to Auth0 allowed URLs |
| 138 | +- Check that auth0 R package is installed |
| 139 | +
|
| 140 | +### Public version showing auth errors |
| 141 | +- The app should auto-detect Shinylive and skip auth |
| 142 | +- If not, check the environment detection logic |
0 commit comments