Merge pull request #4 from correasebastian/feature/add-actions #1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Branch Comparison Analysis and Deployment | |
| on: | |
| schedule: | |
| - cron: '*/5 * * * *' # Run every 5 minutes | |
| workflow_dispatch: # Allow manual trigger | |
| push: | |
| branches: | |
| - release # Run on pushes to release branch | |
| jobs: | |
| analyze-and-deploy: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for pushing to gh-pages | |
| pages: write # Needed for GitHub Pages deployment | |
| id-token: write # Needed for GitHub Pages deployment | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.10' | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install PyGithub | |
| - name: Configure Git | |
| run: | | |
| git config user.name "GitHub Actions Bot" | |
| git config user.email "actions@github.com" | |
| - name: Run branch analysis for latest | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
| GITHUB_REPO: ${{ github.repository }} | |
| MAIN_BRANCH: main | |
| RELEASE_BRANCH: release | |
| run: | | |
| # Run analysis for latest | |
| python github_branch_analyzer_with_date.py | |
| python analyze_branch_data_with_date.py | |
| - name: Run branch analysis for past dates | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GH_PAT }} | |
| GITHUB_REPO: ${{ github.repository }} | |
| MAIN_BRANCH: main | |
| RELEASE_BRANCH: release | |
| run: | | |
| # Run analysis for past 7 days | |
| for i in {1..7}; do | |
| date=$(date -d "$i days ago" +%Y-%m-%d) | |
| echo "Running analysis for $date" | |
| python github_branch_analyzer_with_date.py --date $date --output "branch_data_$(date -d "$date" +%Y%m%d).json" | |
| python analyze_branch_data_with_date.py "branch_data_$(date -d "$date" +%Y%m%d).json" "analyzed_branch_data_$(date -d "$date" +%Y%m%d).json" | |
| done | |
| - name: Setup visualization directory | |
| run: | | |
| # Create visualization directory if it doesn't exist | |
| mkdir -p visualization | |
| # Copy visualization files | |
| cp -r git-branch-comparison-website/* visualization/ | |
| # Copy analysis results | |
| cp analyzed_branch_data*.json visualization/ | |
| - name: Deploy to GitHub Pages | |
| uses: JamesIves/github-pages-deploy-action@v4 | |
| with: | |
| folder: visualization | |
| branch: gh-pages | |
| clean: true |