Weekly Report #5
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: Weekly Report | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| range_from: | |
| description: '开始日期 (YYYY-MM-DD)' | |
| required: false | |
| range_to: | |
| description: '结束日期 (YYYY-MM-DD)' | |
| required: false | |
| schedule: | |
| - cron: '0 1 * * FRI' # 每周五 09:00 北京时间 | |
| jobs: | |
| generate: | |
| runs-on: ubuntu-latest | |
| env: | |
| # 在仓库 Settings -> Secrets and variables -> Actions -> Variables 配置 | |
| # 比如:TARGET_REPO="org/repo1 org/repo2" | |
| TARGET_REPO: ${{ vars.TARGET_REPO }} | |
| steps: | |
| - name: Checkout automation repo | |
| uses: actions/checkout@v4 | |
| - name: Clone target repos | |
| if: ${{ env.TARGET_REPO != '' }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| mkdir -p repos | |
| REPO_PATHS="" | |
| for repo in $TARGET_REPO; do | |
| dir="repos/$(echo "$repo" | tr '/:' '-_')" | |
| git clone "https://${GITHUB_TOKEN}@github.com/${repo}.git" "$dir" >/dev/null 2>&1 | |
| REPO_PATHS+="$(pwd)/$dir " | |
| done | |
| echo "REPO_PATHS=$REPO_PATHS" >> "$GITHUB_ENV" | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - uses: dtolnay/rust-toolchain@stable | |
| - name: Install Linux dependencies | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Inject LLM API key | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| run: | | |
| sed -i 's/\${OPENAI_API_KEY}/'"$OPENAI_API_KEY"'/g' config.cli.json | |
| - name: Generate weekly report | |
| env: | |
| REPORT_FILE: artifacts/report-weekly.md | |
| CONFIG_FILE: config.cli.json | |
| run: | | |
| # 设置默认日期:当天为结束日期,前一周为开始日期 | |
| if [ -z "${{ inputs.range_to }}" ]; then | |
| RANGE_TO=$(date +%Y-%m-%d) | |
| else | |
| RANGE_TO="${{ inputs.range_to }}" | |
| fi | |
| if [ -z "${{ inputs.range_from }}" ]; then | |
| RANGE_FROM=$(date -d "$RANGE_TO - 7 days" +%Y-%m-%d 2>/dev/null || date -v-7d -j -f "%Y-%m-%d" "$RANGE_TO" +%Y-%m-%d) | |
| else | |
| RANGE_FROM="${{ inputs.range_from }}" | |
| fi | |
| export RANGE_FROM RANGE_TO | |
| echo "日期范围: $RANGE_FROM 至 $RANGE_TO" | |
| chmod +x scripts/generate-weekly-report.sh | |
| scripts/generate-weekly-report.sh | |
| - name: Push to Feishu | |
| env: | |
| FEISHU_APP_ID: ${{ secrets.FEISHU_APP_ID }} | |
| FEISHU_APP_SECRET: ${{ secrets.FEISHU_APP_SECRET }} | |
| FEISHU_USER_OPEN_IDS: ${{ secrets.FEISHU_USER_OPEN_IDS }} | |
| REPORT_FILE: artifacts/report-weekly.md | |
| REPORT_TITLE: '自动周报' | |
| REPORT_SUMMARY: '' | |
| run: npx tsx scripts/push-feishu.ts | |
| # - name: Push to Dingtalk | |
| # env: | |
| # DINGTALK_WEBHOOK: ${{ secrets.DINGTALK_WEBHOOK }} | |
| # DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }} | |
| # REPORT_FILE: artifacts/report-weekly.md | |
| # REPORT_TITLE: '自动周报' | |
| # run: npx tsx scripts/push-dingtalk.ts | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: weekly-report | |
| path: artifacts/report-weekly.md |