Skip to content

.github/workflows/crawl.yml #790

.github/workflows/crawl.yml

.github/workflows/crawl.yml #790

Workflow file for this run

on:
# 定时任务,每天在国际标准时间23点(北京时间早上7点)运行
schedule:
- cron: '0 23 * * *'
workflow_dispatch:
# 一个 CI/CD 的工作流有许多 jobs 组成,比如最典型的 job 是 lint,test,build。
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Get current date
id: date
run: echo "{date}={$(date +'%Y-%m-%d')}" >> $GITHUB_OUTPUT
- name: Checkout
uses: actions/checkout@v4
- name: Install node
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Crawling
env:
BAIDU_COOKIE: ${{ secrets.BAIDU_COOKIE }}
EuDic_COOKIE: ${{ secrets.EUDIC_COOKIE }}
run: npm install && npm run dev
- name: Config git info
env:
GITHUB_USER: ${{ github.actor }}
GITHUB_EMAIL: ${{ github.actor }}@users.noreply.github.com
run: |
git config --global user.email "$GITHUB_EMAIL"
git config --global user.name "$GITHUB_USER"
- name: Commit changes and Push
env:
GITHUB_LOGIN: ${{ github.actor }}
GITHUB_PERSONAL_TOKEN: ${{ secrets.GITHUB_PERSONAL_TOKEN }}
run: |
if [[ `git status data --porcelain` ]]; then
git add data
git commit -m "feat(data): auto-crawl ${{ steps.date.outputs.date }}"
git push https://$GITHUB_LOGIN:$GITHUB_PERSONAL_TOKEN@github.com/$GITHUB_REPOSITORY.git
else
echo "WARNING: No changes were detected. git commit push action aborted."
fi