|
| 1 | +# GitHub Branch Analyzer - Deployment Guide |
| 2 | + |
| 3 | +This guide explains how to deploy the GitHub Branch Analyzer with date filtering to GitHub Pages using GitHub Actions. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +This deployment method will: |
| 8 | +1. Automatically run branch analysis on a schedule (daily by default) |
| 9 | +2. Generate visualizations for multiple dates |
| 10 | +3. Deploy the results to GitHub Pages |
| 11 | +4. Make the visualization accessible via a public URL |
| 12 | + |
| 13 | +## Prerequisites |
| 14 | + |
| 15 | +- A GitHub repository where you want to deploy the visualization |
| 16 | +- Admin access to the repository to configure GitHub Pages and secrets |
| 17 | +- A GitHub Personal Access Token (PAT) with appropriate permissions |
| 18 | + |
| 19 | +## Step 1: Set Up Your Repository |
| 20 | + |
| 21 | +1. Create a new repository or use an existing one |
| 22 | +2. Clone this repository to your local machine: |
| 23 | + ```bash |
| 24 | + git clone https://github.com/yourusername/your-repository.git |
| 25 | + cd your-repository |
| 26 | + ``` |
| 27 | + |
| 28 | +3. Copy all the files from the GitHub Branch Analyzer into your repository: |
| 29 | + - `.github/workflows/branch-analysis.yml` |
| 30 | + - `_config.yml` |
| 31 | + - `github_branch_analyzer_for_actions.py` |
| 32 | + - `analyze_branch_data_for_actions.py` |
| 33 | + - All files from the `git-branch-comparison-website` directory |
| 34 | + |
| 35 | +## Step 2: Create a Personal Access Token |
| 36 | + |
| 37 | +1. Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens |
| 38 | +2. Click "Generate new token" |
| 39 | +3. Give it a name like "Branch Analyzer Deployment" |
| 40 | +4. Set the expiration as needed (e.g., 1 year) |
| 41 | +5. Select the repository you want to analyze |
| 42 | +6. Under "Repository permissions", grant: |
| 43 | + - Contents: Read and write |
| 44 | + - Pull requests: Read |
| 45 | + - Metadata: Read |
| 46 | + - Pages: Read and write |
| 47 | +7. Click "Generate token" and copy the token value |
| 48 | + |
| 49 | +## Step 3: Configure Repository Secrets |
| 50 | + |
| 51 | +1. Go to your repository on GitHub |
| 52 | +2. Click on "Settings" → "Secrets and variables" → "Actions" |
| 53 | +3. Click "New repository secret" |
| 54 | +4. Add a secret with name `GH_PAT` and paste your Personal Access Token as the value |
| 55 | +5. Click "Add secret" |
| 56 | + |
| 57 | +## Step 4: Configure GitHub Pages |
| 58 | + |
| 59 | +1. Go to your repository on GitHub |
| 60 | +2. Click on "Settings" → "Pages" |
| 61 | +3. Under "Source", select "GitHub Actions" as the build and deployment source |
| 62 | +4. This will allow the workflow to handle the deployment |
| 63 | + |
| 64 | +## Step 5: Customize the Workflow (Optional) |
| 65 | + |
| 66 | +You can customize the workflow by editing `.github/workflows/branch-analysis.yml`: |
| 67 | + |
| 68 | +1. Change the schedule: |
| 69 | + ```yaml |
| 70 | + schedule: |
| 71 | + - cron: '0 0 * * *' # Default: Run daily at midnight |
| 72 | + ``` |
| 73 | +
|
| 74 | +2. Modify the branches to analyze: |
| 75 | + ```yaml |
| 76 | + env: |
| 77 | + MAIN_BRANCH: main # Change to your main branch name |
| 78 | + RELEASE_BRANCH: release # Change to your release branch name |
| 79 | + ``` |
| 80 | +
|
| 81 | +3. Adjust the number of historical dates: |
| 82 | + ```yaml |
| 83 | + # Run analysis for past 7 days |
| 84 | + for i in {1..7}; do # Change 7 to your desired number of days |
| 85 | + ``` |
| 86 | + |
| 87 | +## Step 6: Push Changes and Trigger the Workflow |
| 88 | + |
| 89 | +1. Commit and push all changes to your repository: |
| 90 | + ```bash |
| 91 | + git add . |
| 92 | + git commit -m "Add GitHub Branch Analyzer with GitHub Actions deployment" |
| 93 | + git push |
| 94 | + ``` |
| 95 | + |
| 96 | +2. This will automatically trigger the workflow for the first time |
| 97 | + |
| 98 | +3. You can also manually trigger the workflow: |
| 99 | + - Go to your repository on GitHub |
| 100 | + - Click on "Actions" |
| 101 | + - Select the "Branch Comparison Analysis and Deployment" workflow |
| 102 | + - Click "Run workflow" |
| 103 | + |
| 104 | +## Step 7: Access Your Deployed Visualization |
| 105 | + |
| 106 | +1. After the workflow completes successfully: |
| 107 | + - Go to your repository on GitHub |
| 108 | + - Click on "Settings" → "Pages" |
| 109 | + - You'll see a message like "Your site is published at https://yourusername.github.io/your-repository/" |
| 110 | + |
| 111 | +2. Visit the URL to access your branch comparison visualization |
| 112 | + |
| 113 | +3. The visualization will be automatically updated according to your workflow schedule |
| 114 | + |
| 115 | +## Troubleshooting |
| 116 | + |
| 117 | +### Workflow Failures |
| 118 | + |
| 119 | +If the workflow fails: |
| 120 | +1. Go to "Actions" in your repository |
| 121 | +2. Click on the failed workflow run |
| 122 | +3. Examine the logs to identify the issue |
| 123 | + |
| 124 | +Common issues include: |
| 125 | +- Invalid Personal Access Token |
| 126 | +- Insufficient permissions |
| 127 | +- Repository not found |
| 128 | +- Branch names don't exist in your repository |
| 129 | + |
| 130 | +### GitHub Pages Not Deploying |
| 131 | + |
| 132 | +If GitHub Pages doesn't deploy: |
| 133 | +1. Verify that GitHub Pages is enabled for your repository |
| 134 | +2. Check that the workflow has the correct permissions |
| 135 | +3. Ensure the `gh-pages` branch was created by the workflow |
| 136 | + |
| 137 | +### Visualization Not Showing Data |
| 138 | + |
| 139 | +If the visualization loads but doesn't show data: |
| 140 | +1. Check that the analysis scripts ran successfully |
| 141 | +2. Verify that JSON files were generated and copied to the visualization directory |
| 142 | +3. Check browser console for JavaScript errors |
| 143 | + |
| 144 | +## Advanced Configuration |
| 145 | + |
| 146 | +### Custom Domain |
| 147 | + |
| 148 | +To use a custom domain: |
| 149 | +1. Go to "Settings" → "Pages" |
| 150 | +2. Under "Custom domain", enter your domain |
| 151 | +3. Update DNS settings as instructed |
| 152 | + |
| 153 | +### Additional Analysis Dates |
| 154 | + |
| 155 | +To analyze more historical dates: |
| 156 | +1. Edit the workflow file |
| 157 | +2. Modify the loop that generates historical dates |
| 158 | +3. Consider performance implications for very large repositories |
| 159 | + |
| 160 | +### Automatic Updates |
| 161 | + |
| 162 | +The visualization will automatically update based on your workflow schedule. To change this: |
| 163 | +1. Edit the `schedule` section in the workflow file |
| 164 | +2. Use cron syntax to define your preferred schedule |
| 165 | + |
| 166 | +## Conclusion |
| 167 | + |
| 168 | +Your GitHub Branch Analyzer is now deployed to GitHub Pages and will automatically update according to your schedule. The visualization provides insights into your branch merging patterns over time, helping you understand your development workflow better. |
0 commit comments