This guide explains how to deploy the GitHub Branch Analyzer with date filtering to GitHub Pages using GitHub Actions.
This deployment method will:
- Automatically run branch analysis on a schedule (daily by default)
- Generate visualizations for multiple dates
- Deploy the results to GitHub Pages
- Make the visualization accessible via a public URL
- A GitHub repository where you want to deploy the visualization
- Admin access to the repository to configure GitHub Pages and secrets
- A GitHub Personal Access Token (PAT) with appropriate permissions
-
Create a new repository or use an existing one
-
Clone this repository to your local machine:
git clone https://github.com/yourusername/your-repository.git cd your-repository -
Copy all the files from the GitHub Branch Analyzer into your repository:
.github/workflows/branch-analysis.yml_config.ymlgithub_branch_analyzer_for_actions.pyanalyze_branch_data_for_actions.py- All files from the
git-branch-comparison-websitedirectory
- Go to GitHub → Settings → Developer settings → Personal access tokens → Fine-grained tokens
- Click "Generate new token"
- Give it a name like "Branch Analyzer Deployment"
- Set the expiration as needed (e.g., 1 year)
- Select the repository you want to analyze
- Under "Repository permissions", grant:
- Contents: Read and write
- Pull requests: Read
- Metadata: Read
- Pages: Read and write
- Click "Generate token" and copy the token value
- Go to your repository on GitHub
- Click on "Settings" → "Secrets and variables" → "Actions"
- Click "New repository secret"
- Add a secret with name
GH_PATand paste your Personal Access Token as the value - Click "Add secret"
- Go to your repository on GitHub
- Click on "Settings" → "Pages"
- Under "Source", select "GitHub Actions" as the build and deployment source
- This will allow the workflow to handle the deployment
You can customize the workflow by editing .github/workflows/branch-analysis.yml:
-
Change the schedule:
schedule: - cron: '0 0 * * *' # Default: Run daily at midnight
-
Modify the branches to analyze:
env: MAIN_BRANCH: main # Change to your main branch name RELEASE_BRANCH: release # Change to your release branch name
-
Adjust the number of historical dates:
# Run analysis for past 7 days for i in {1..7}; do # Change 7 to your desired number of days
-
Commit and push all changes to your repository:
git add . git commit -m "Add GitHub Branch Analyzer with GitHub Actions deployment" git push
-
This will automatically trigger the workflow for the first time
-
You can also manually trigger the workflow:
- Go to your repository on GitHub
- Click on "Actions"
- Select the "Branch Comparison Analysis and Deployment" workflow
- Click "Run workflow"
-
After the workflow completes successfully:
- Go to your repository on GitHub
- Click on "Settings" → "Pages"
- You'll see a message like "Your site is published at https://yourusername.github.io/your-repository/"
-
Visit the URL to access your branch comparison visualization
-
The visualization will be automatically updated according to your workflow schedule
If the workflow fails:
- Go to "Actions" in your repository
- Click on the failed workflow run
- Examine the logs to identify the issue
Common issues include:
- Invalid Personal Access Token
- Insufficient permissions
- Repository not found
- Branch names don't exist in your repository
If GitHub Pages doesn't deploy:
- Verify that GitHub Pages is enabled for your repository
- Check that the workflow has the correct permissions
- Ensure the
gh-pagesbranch was created by the workflow
If the visualization loads but doesn't show data:
- Check that the analysis scripts ran successfully
- Verify that JSON files were generated and copied to the visualization directory
- Check browser console for JavaScript errors
To use a custom domain:
- Go to "Settings" → "Pages"
- Under "Custom domain", enter your domain
- Update DNS settings as instructed
To analyze more historical dates:
- Edit the workflow file
- Modify the loop that generates historical dates
- Consider performance implications for very large repositories
The visualization will automatically update based on your workflow schedule. To change this:
- Edit the
schedulesection in the workflow file - Use cron syntax to define your preferred schedule
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.