Skip to content

LeetCode Daily Problems #467

LeetCode Daily Problems

LeetCode Daily Problems #467

Workflow file for this run

name: LeetCode Daily Problems
on:
workflow_dispatch: # manually trigger
schedule:
- cron: '0 16 * * *' # run every day at midnight
jobs:
scrape:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
sparse-checkout: |
.github
cpp
golang
python
qubhjava
typescript
rust
go.mod
go.sum
pom.xml
MODULE.bazel
tsconfig.json
package.json
jest.config.ts
Cargo.toml
data
${{ secrets.PROBLEM_FOLDER || 'problems' }}
${{ secrets.PREMIUM_FOLDER || 'premiums' }}
- name: Set up Python environment
uses: actions/setup-python@v2
with:
python-version: '3.12'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r python/requirements.txt
- name: Run script
id: script
env:
COOKIE: ${{ secrets.COOKIE }}
PUSH_SERVER: ${{ secrets.PUSH_SERVER }}
PUSH_KEY: ${{ secrets.PUSH_KEY || '' }}
PROBLEM_FOLDER: ${{ secrets.PROBLEM_FOLDER || '' }}
LANGUAGES: ${{secrets.LANGUAGES || ''}}
LOG_LEVEL: ${{secrets.LOG_LEVEL || 'INFO'}}
run: |
set +e
python python/scripts/daily_auto.py > /tmp/msg 2>&1
status=$?
cat /tmp/msg
echo "QUESTION_IDS=$(grep 'Add question:' /tmp/msg | cut -d '[' -f 6 | cut -d ']' -f 1 | tr '\n' ' ' | sed 's/ $//')" >> $GITHUB_ENV
echo "question lines: $(grep 'Add question:' /tmp/msg)"
echo "question ids: $(grep 'Add question:' /tmp/msg | cut -d '[' -f 6 | cut -d ']' -f 1)"
echo "QUESTION_IDS=$(grep 'Add question:' /tmp/msg | cut -d '[' -f 6 | cut -d ']' -f 1 | tr '\n' ' ' | sed 's/ $//')"
exit $status
- name: Commit files
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add .
if git diff --staged --quiet; then
echo "No changes to commit"
exit 0
fi
cat /tmp/msg
echo "question_ids: ${{ env.QUESTION_IDS }}"
git commit -m "test: [$(TZ=Asia/Shanghai date +%Y%m%d)] Add (${{ env.QUESTION_IDS }})"
- name: Push changes
run: |
if git log origin/${{ github.ref_name }}..HEAD --oneline | read; then
git push
else
echo "No changes to push"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Delete workflow runs
uses: GitRML/delete-workflow-runs@main
with:
retain_days: 3
keep_minimum_runs: 1
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
- name: Clean up Old releases
uses: dev-drprasad/[email protected]
with:
keep_latest: 3
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}