Skip to content

Update README with LeetCode Daily Challenge #3

Update README with LeetCode Daily Challenge

Update README with LeetCode Daily Challenge #3

Workflow file for this run

name: Update README with LeetCode Daily Challenge
on:
schedule:
- cron: '1 0 * * *' # Runs daily at 00:01 UTC
workflow_dispatch: # Allows for manual triggering
jobs:
update-readme:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests beautifulsoup4
- name: Run update_readme.py
id: update_readme
run: python update_readme.py
- name: Create GitHub issue on failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issueTitle = "Update README with LeetCode Daily Challenge Failed";
const issueBody = `
The GitHub Action to update README with LeetCode Daily Challenge has failed.
Please check the workflow logs for more details.
`;
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'bug',
});
const issueExists = existingIssues.data.find(issue => issue.title === issueTitle);
if (!issueExists) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: issueTitle,
body: issueBody,
labels: ['bug'],
});
} else {
console.log(`An issue with the title "${issueTitle}" already exists.`);
}