Skip to content

ISSUE

ISSUE #1027

Workflow file for this run

name: ISSUE
on:
issues:
types: [opened]
jobs:
add-labels:
runs-on: ubuntu-latest
if: join(github.event.issue.labels) == ''
steps:
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Change Name
uses: actions-cool/issues-helper@v3
with:
actions: 'update-issue'
token: ${{ secrets.MY_GITHUB_TOKEN }}
issue-number: ${{ github.event.issue.number }}
labels: pick
title: "[${{ steps.date.outputs.date }}] ${{ github.event.issue.title }}"
push-issue:
runs-on: ubuntu-latest
if: join(github.event.issue.labels) == ''
steps:
- name: Checkout master branch
uses: actions/checkout@v3
with:
ref: master
fetch-depth: 0
- name: Configure Git for long paths
run: git config --global core.longpaths true
- name: Checkout archive branch to archive directory
run: |
git fetch origin archive:archive 2>/dev/null || echo "Archive branch does not exist yet"
mkdir -p archive
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.10'
- name: Cache pip
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
- name: Install dependencies
run: ./install.sh
- name: Update Body and Generate Summary
run: python3 picker.py --push-issue ${{ github.event.issue.number }}
env:
FEISHU_KEY: ${{ secrets.FEISHU_KEY }}
PICKER_FEISHU_KEY: ${{ secrets.PICKER_FEISHU_KEY }}
WECOM_KEY: ${{ secrets.WECOM_KEY }}
DINGTALK_KEY: ${{ secrets.DINGTALK_KEY }}
DINGTALK_SECRET: ${{ secrets.DINGTALK_SECRET }}
PICKER_DINGTALK_KEY: ${{ secrets.PICKER_DINGTALK_KEY }}
PICKER_DINGTALK_SECRET: ${{ secrets.PICKER_DINGTALK_SECRET }}
QQ_KEY: ${{ secrets.QQ_KEY }}
TELEGRAM_KEY: ${{ secrets.TELEGRAM_KEY }}
MAIL_KEY: ${{ secrets.MAIL_KEY }}
MAIL_RECEIVER: ${{ secrets.MAIL_RECEIVER }}
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
- name: Generate AI Summary
run: python3 picker.py --summarize-issue ${{ github.event.issue.number }}
env:
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
FEISHU_KEY: ${{ secrets.FEISHU_KEY }}
PICKER_FEISHU_KEY: ${{ secrets.PICKER_FEISHU_KEY }}
- name: Commit article markdown to archive branch
run: |
git config --global user.email [email protected]
git config --global user.name chainreactorbot
# Stash any changes in master branch if they exist
git stash push -m "Temporary stash before switching to archive" || true
# Move archive directory to temporary location to avoid conflicts
year=$(date +'%Y')
month=$(date +'%m')
day=$(date +'%d')
temp_archive="/tmp/archive_temp_${year}_${month}_${day}"
if [ -d "archive/${year}/${month}/${day}" ]; then
mkdir -p "$temp_archive"
mv "archive/${year}/${month}/${day}" "$temp_archive/"
fi
# Switch to archive branch
git fetch origin archive
if git show-ref --verify --quiet refs/heads/archive; then
git checkout -f archive
else
git checkout -b archive origin/archive || git checkout --orphan archive
fi
# Move files back
if [ -d "$temp_archive/${day}" ]; then
mkdir -p "archive/${year}/${month}"
mv "$temp_archive/${day}" "archive/${year}/${month}/"
fi
# Add changes to archive
git add "archive/${year}/${month}/${day}/"
# Commit if there are changes
git diff --staged --quiet || git commit -m "添加文章 markdown(Issue #${{ github.event.issue.number }})"
# Push to archive branch
git push origin archive