HackerNews Crawler #1080
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: HackerNews Crawler | |
| on: | |
| # push: | |
| # branches: | |
| # - master | |
| schedule: | |
| # - cron: '*/15 15-23,0-14 * * *' # Run every 15 minutes from 7:00 to 00:00 (UTC+8) | |
| - cron: '30 23,11 * * *' # 7:30 AM and 7:30 PM UTC+8 (23:30 and 11:30 UTC) | |
| workflow_dispatch: | |
| inputs: | |
| enable_llm: | |
| description: Generate or refresh Perspectives (incurs API cost) | |
| required: true | |
| default: false | |
| type: boolean | |
| jobs: | |
| crawl-hackernews: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write # Needed for creating releases | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v5 | |
| - name: "Set up Python" | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version-file: "pyproject.toml" | |
| - name: Install dependencies | |
| run: | | |
| uv sync --all-extras --dev | |
| - name: Restore cache folder | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: cache/ | |
| key: hackernews-cache-${{ github.run_id }} | |
| restore-keys: | | |
| hackernews-cache- | |
| - name: Set NOW variable | |
| id: set_now | |
| run: | | |
| echo "NOW=$(TZ=Asia/Shanghai date '+%Y-%m-%d %H:%M:%S %z')" >> $GITHUB_ENV | |
| - name: Run crawler | |
| env: | |
| ENABLE_LLM: ${{ inputs.enable_llm || 'false' }} | |
| SMOLLLM_MODEL: ${{ vars.SMOLLLM_MODEL }} | |
| SMOLSERVER_API_KEY: ${{ secrets.SMOLSERVER_API_KEY }} | |
| SMOLSERVER_BASE_URL: ${{ vars.SMOLSERVER_BASE_URL }} | |
| run: uv run main.py | |
| - name: Save cache folder | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: cache/ | |
| key: hackernews-cache-${{ github.run_id }} | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| name: "HN TOP ${{ env.NOW }}" | |
| tag_name: latest | |
| body_path: cache/hackernews.md | |
| files: | | |
| cache/* | |
| prerelease: false |