mirror of
https://github.com/vinta/awesome-python.git
synced 2026-04-11 02:11:42 +08:00
ci: merge build/deploy jobs and cache stars by date
Collapse the two-job workflow into one, set the github-pages environment on the single job, and key the star-data cache by date (YYYY-MM-DD) so it is shared across same-day runs instead of being per-run-id. Also skip tests on scheduled runs and validate JSON before serving it. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
e1869aa28d
commit
54864ab37a
33
.github/workflows/ci.yml
vendored
Normal file
33
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
- name: Install uv
|
||||
uses: astral-sh/setup-uv@v7
|
||||
with:
|
||||
enable-cache: true
|
||||
|
||||
- name: Install dependencies
|
||||
run: uv sync --group build
|
||||
|
||||
- name: Run tests
|
||||
run: make test
|
||||
|
||||
- name: Build website
|
||||
run: make build
|
||||
26
.github/workflows/deploy-website.yml
vendored
26
.github/workflows/deploy-website.yml
vendored
@ -17,8 +17,11 @@ concurrency:
|
||||
cancel-in-progress: false
|
||||
|
||||
jobs:
|
||||
build:
|
||||
deploy:
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: https://awesome-python.com/
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
|
||||
@ -31,14 +34,19 @@ jobs:
|
||||
run: uv sync --group build
|
||||
|
||||
- name: Run tests
|
||||
if: github.event_name != 'schedule'
|
||||
run: make test
|
||||
|
||||
- name: Get date
|
||||
id: date
|
||||
run: echo "today=$(date -u +%Y-%m-%d)" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Restore star data cache
|
||||
id: cache-stars
|
||||
uses: actions/cache/restore@v4
|
||||
with:
|
||||
path: website/data/github_stars.json
|
||||
key: github-stars-${{ github.run_id }}
|
||||
key: github-stars-${{ steps.date.outputs.today }}
|
||||
restore-keys: github-stars-
|
||||
|
||||
- name: Fetch GitHub stars
|
||||
@ -53,7 +61,7 @@ jobs:
|
||||
uses: actions/cache/save@v4
|
||||
with:
|
||||
path: website/data/github_stars.json
|
||||
key: github-stars-${{ github.run_id }}
|
||||
key: github-stars-${{ steps.date.outputs.today }}
|
||||
|
||||
- name: Verify star data exists
|
||||
run: |
|
||||
@ -61,9 +69,9 @@ jobs:
|
||||
echo "::error::github_stars.json not found. No cache and fetch failed or was skipped."
|
||||
exit 1
|
||||
fi
|
||||
echo "Star data found: $(wc -l < website/data/github_stars.json) lines"
|
||||
python -m json.tool website/data/github_stars.json > /dev/null
|
||||
|
||||
- name: Build site
|
||||
- name: Build website
|
||||
run: make build
|
||||
|
||||
- name: Upload artifact
|
||||
@ -71,13 +79,5 @@ jobs:
|
||||
with:
|
||||
path: website/output/
|
||||
|
||||
deploy:
|
||||
needs: build
|
||||
runs-on: ubuntu-latest
|
||||
environment:
|
||||
name: github-pages
|
||||
url: https://awesome-python.com/
|
||||
steps:
|
||||
- name: Deploy to GitHub Pages
|
||||
id: deployment
|
||||
uses: actions/deploy-pages@v4
|
||||
|
||||
Loading…
Reference in New Issue
Block a user