Check Dependencies #8
This file contains 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: Check Dependencies | |
on: | |
schedule: | |
- cron: '0 12 */2 * *' # Run at noon UTC every other day | |
workflow_dispatch: # Allow manual triggers | |
jobs: | |
check-updates: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: pip install requests packaging | |
- name: Check for updates | |
id: check | |
run: python .github/scripts/check_vendordeps.py | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Handle Update Issues | |
if: steps.check.outputs.has_updates == 'true' | |
uses: actions/github-script@v6 | |
env: | |
UPDATES_JSON: ${{ steps.check.outputs.updates }} | |
with: | |
script: | | |
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`; | |
body += `- Current version: ${update.current}\n`; | |
body += `- Latest version: ${update.latest}\n`; | |
body += `- Source: ${update.source}\n`; | |
if (update.url) { | |
body += `- [View Release](${update.url})\n`; | |
} | |
if (update.name === 'WPILib') { | |
body += '\n⚠️ **Note**: Please use WPILib VS Code tools for actual updates\n'; | |
if (update.notes) { | |
body += '\n<details><summary>Release Notes</summary>\n\n'; | |
body += update.notes; | |
body += '\n</details>\n'; | |
} | |
} | |
body += '\n'; | |
} | |
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); | |
console.log('Updates JSON:', process.env.UPDATES_JSON); | |
} |