LeetCode Submit Checker #597
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: LeetCode Submit Checker | |
| on: | |
| workflow_dispatch: # manually trigger | |
| schedule: | |
| - cron: '0 14 * * *' # 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 | |
| go.mod | |
| go.sum | |
| pom.xml | |
| WORKSPACE | |
| tsconfig.json | |
| package.json | |
| jest.config.ts | |
| ${{ secrets.PROBLEM_FOLDER || 'problems' }} | |
| ${{ secrets.PREMIUM_FOLDER || 'premiums' }} | |
| - name: Set up Python environment | |
| uses: actions/setup-python@v2 | |
| with: | |
| python-version: '3.12' | |
| - name: Set up Golang environment | |
| continue-on-error: true | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.22' | |
| - name: Set up JDK | |
| continue-on-error: true | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '21' | |
| distribution: 'temurin' | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Set up TypeScript | |
| continue-on-error: true | |
| run: | | |
| npm install | |
| npm audit fix --force | |
| - name: Install python dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -r python/requirements.txt | |
| - name: Build with Maven | |
| continue-on-error: true | |
| run: | | |
| mvn clean validate | |
| - name: Setup Bazel | |
| continue-on-error: true | |
| uses: bazel-contrib/setup-bazel@0.8.5 | |
| with: | |
| # Avoid downloading Bazel every time. | |
| bazelisk-cache: true | |
| # Store build cache per workflow. | |
| disk-cache: ${{ github.workflow }} | |
| # Share repository cache between workflows. | |
| repository-cache: true | |
| bazelrc: | | |
| build --color=yes | |
| build --show_timestamps | |
| build --cxxopt=-std=c++20 | |
| test --cxxopt=-std=c++20 | |
| - name: Run script | |
| env: | |
| COOKIE: ${{ secrets.COOKIE || '' }} | |
| PUSH_SERVER: ${{ secrets.PUSH_SERVER || '' }} | |
| PUSH_KEY: ${{ secrets.PUSH_KEY || '' }} | |
| PROBLEM_FOLDER: ${{ secrets.PROBLEM_FOLDER || '' }} | |
| LANGUAGES: ${{secrets.LANGUAGES || ''}} | |
| USER: ${{ secrets.USER }} | |
| run: | | |
| set +e | |
| python python/scripts/daily_submission.py &> /tmp/msg | |
| status=$? | |
| cat /tmp/msg | |
| exit $status | |
| - name: Commit files | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| exit 0 | |
| fi | |
| git commit -m "[$(TZ=Asia/Shanghai date +%Y%m%d)] Add daily problem solution" | |
| - 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 }} |