Skip to content

infiv

infiv #35

Workflow file for this run

name: infiv
on:
schedule:
- cron: '15 3 * * *' # 3:15 @ UTC, should be a bit early to encounter the schedule github action delay, this setting get results in average 3:30 UTC
workflow_dispatch:
inputs:
EXPIRED_DAYTIME:
description: 'Optional expired datetime(format "YYYY/MM/DD HH:MM" in UTC), if not set it would be yesterday'
required: false
permissions:
contents: read
issues: write # allow writing to issue
pages: write
id-token: write
jobs:
push:
runs-on: ubuntu-latest
env:
ZHIHU_COOKIE: ${{ secrets.ZHIHU_COOKIE }}
BILIBILI_COOKIE: ${{ secrets.BILIBILI_COOKIE }}
GOOGLE_API_KEY: ${{ secrets.GOOGLE_API_KEY }}
BASE_URL: /${{ github.event.repository.name }}
steps:
- name: Set EXPIRED_DAYTIME for workflow_dispatch
if: ${{ github.event_name == 'workflow_dispatch' }}
run: |
if [ -z "${{ github.event.inputs.EXPIRED_DAYTIME }}" ]; then
EXPIRED_DAYTIME=$(date -d 'yesterday' '+%Y/%m/%d %H:%M')
else
EXPIRED_DAYTIME="${{ github.event.inputs.EXPIRED_DAYTIME }}"
fi
echo "EXPIRED_DAYTIME=$EXPIRED_DAYTIME"
echo "EXPIRED_DAYTIME=$EXPIRED_DAYTIME" >> $GITHUB_ENV
- name: Get last successful run and set EXPIRED_DAYTIME for schedule
if: ${{ github.event_name == 'schedule' }}
run: |
# Get the most recent successful scheduled workflow run using GitHub API
runs=$(curl -s -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/workflows/${{ github.workflow }}/runs?event=schedule&status=success&per_page=1")
# Extract the last successful run time
last_run_time=$(echo "$runs" | jq -r '.workflow_runs[0].updated_at')
if [ -z "$last_run_time" ] || [ "$last_run_time" = "null" ]; then
# If no successful run is found, set EXPIRED_DAYTIME to yesterday's date and current time
EXPIRED_DAYTIME=$(date -d 'yesterday' '+%Y/%m/%d %H:%M')
else
# Format the last successful run time to "YYYY/MM/DD HH:MM"
EXPIRED_DAYTIME=$(date -d "$last_run_time" '+%Y/%m/%d %H:%M')
fi
echo "last_run_time=$last_run_time"
echo "EXPIRED_DAYTIME=$EXPIRED_DAYTIME"
echo "EXPIRED_DAYTIME=$EXPIRED_DAYTIME" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: checkout rsshub modified
uses: actions/checkout@v4
with:
repository: ValMystletainn/RSSHub
path: ./RSSHub
- uses: actions/setup-python@v5
with:
python-version: '3.10'
- uses: actions/setup-node@v4
with:
node-version: 22.x
- name: rsshub server setup
run: | # It should wait for ready but we have to install other dependencies so don't sleep now
cd RSSHub
npm install
npm run build
npm run start &
- name: install dependencies
run: |
cd ${{ github.workspace }}
pip install -e .[rss]
npm install -g mystmd
- name: fetch content and build
env:
EXPIRED_DAYTIME: ${{ env.EXPIRED_DAYTIME }}
run: python -m infiv build --use_embed
- name: to myst pages
run: myst build --html
- uses: actions/upload-artifact@v4
with:
path: output.md
- uses: actions/upload-pages-artifact@v1
with:
path: ./_build/html
- uses: actions/deploy-pages@v2
- name: Upload markdown to issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python -m infiv md2json
# Create a new issue and upload the markdown content
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues \
-d @output.json