Skip to content

Commit

Permalink
Merge pull request #44 from 5152Alotobots/depchecker
Browse files Browse the repository at this point in the history
Add check for duplicate issue
  • Loading branch information
SeanErn authored Dec 23, 2024
2 parents 82b9997 + e5888fd commit 23a8d0e
Showing 1 changed file with 37 additions and 8 deletions.
45 changes: 37 additions & 8 deletions .github/workflows/check_vendordeps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Issue for Updates
- name: Handle Update Issues
if: steps.check.outputs.has_updates == 'true'
uses: actions/github-script@v6
env:
Expand All @@ -35,7 +35,21 @@ jobs:
try {
const updates = JSON.parse(process.env.UPDATES_JSON);
// Search for existing open issues
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'dependencies'
});
// Find existing update issue
const existingIssue = issues.data.find(issue =>
issue.title.includes('Dependency Updates Available')
);
let body = '# Dependency Updates Available\n\n';
body += '_Last checked: ' + new Date().toISOString() + '_\n\n';
for (const update of updates) {
body += `### ${update.name}\n`;
Expand All @@ -59,13 +73,28 @@ jobs:
body += '\n';
}
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🔄 Dependency Updates Available',
body: body,
labels: ['dependencies']
});
if (existingIssue) {
// Update existing issue
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: body
});
console.log(`Updated existing issue #${existingIssue.number}`);
} else {
// Create new issue
const newIssue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🔄 Dependency Updates Available',
body: body,
labels: ['dependencies']
});
console.log(`Created new issue #${newIssue.data.number}`);
}
} catch (error) {
core.setFailed(`Error processing updates: ${error.message}`);
console.log('Full error:', error);
Expand Down

0 comments on commit 23a8d0e

Please sign in to comment.