chore(deps): bump actions/setup-python from 4 to 5 #60
Workflow file for this run
This file contains 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: GitStats Preview | |
on: | |
pull_request: | |
paths: | |
- '**/*.py' | |
- 'pyproject.toml' | |
- 'gitstats.conf' | |
- '.github/workflows/preview.yml' | |
push: | |
branches: | |
- "main" | |
workflow_dispatch: | |
jobs: | |
test-windows: | |
runs-on: windows-latest | |
strategy: | |
matrix: | |
python-version: ["3.9"] # just test on one version to save time | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # get all history. | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install gnuplot | |
run: choco install gnuplot -y --no-progress | |
- name: Generate GitStats Report | |
run: | | |
$env:PATH += ";C:\Program Files\gnuplot\bin" | |
gnuplot --version | |
python -m venv venv | |
.\venv\Scripts\activate.bat | |
# for testing | |
pip install . | |
gitstats . gitstats-report-windows | |
- name: Save GitStats Report | |
if: ${{ matrix.python-version == '3.9' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gitstats-report-windows | |
path: gitstats-report-windows | |
test-linux: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # get all history. | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y gnuplot | |
- name: Generate GitStats Report | |
run: | | |
python3 -m venv venv | |
source venv/bin/activate | |
# for testing | |
pip install . | |
gitstats . gitstats-report | |
- name: Save GitStats Report | |
if: ${{ matrix.python-version == '3.9' }} | |
uses: actions/upload-artifact@v4 | |
with: | |
name: gitstats-report | |
path: gitstats-report | |
- name: Deploy to GitHub Pages for PR | |
if: ${{ github.event_name == 'pull_request' && matrix.python-version == '3.9' }} | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: gitstats-report | |
# Configure a unique preview link for each pull request | |
destination_dir: previews/${{ github.event.pull_request.number }} | |
- name: Deploy to GitHub Pages for main branch | |
if: ${{ (github.ref_name == 'main' || github.event_name == 'workflow_dispatch') && matrix.python-version == '3.9' }} | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
publish_dir: gitstats-report | |
destination_dir: main | |
- name: Add PR Comment with Preview Link | |
if: ${{ github.event_name == 'pull_request' && matrix.python-version == '3.9' }} | |
env: | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
REPO_NAME: ${{ github.repository }} | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
PREVIEW_URL="https://shenxianpeng.github.io/gitstats/previews/${{ env.PR_NUMBER }}/index.html" | |
COMMENT_BODY="π Your GitStats preview is ready: [View Report](${PREVIEW_URL})" | |
gh api repos/${{ env.REPO_NAME }}/issues/${{ env.PR_NUMBER }}/comments -f body="${COMMENT_BODY}" |