Skip to content

updated workflow #9

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 29 additions & 6 deletions .github/workflows/update_readme.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,37 @@ jobs:
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: peter-evans/create-issue-from-file@v2
uses: actions/github-script@v6
with:
title: "Update README with LeetCode Daily Challenge Failed"
content: |
The GitHub Action to update README with LeetCode Daily Challenge has failed.
Please check the workflow logs for more details.
labels: bug
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 { data: existingIssues } = await github.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'bug',
title: issueTitle,
});

if (existingIssues.length === 0) {
await github.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.`);
}