Skip to content

Check Conan Dependencies #390

Check Conan Dependencies

Check Conan Dependencies #390

name: Check Conan Dependencies
on:
schedule:
# Run every day at 9:00 AM UTC
- cron: '0 9 * * *'
workflow_dispatch: # Allow manual trigger
pull_request:
paths:
- 'conanfile.py'
- 'scripts/check_conan_updates.py'
- '.github/workflows/check-conan-updates.yml'
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
check-updates:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pyyaml
- name: Check for Conan package updates
id: check
run: |
python scripts/check_conan_updates.py > update_report.txt 2>&1
echo "exit_code=$?" >> $GITHUB_OUTPUT
continue-on-error: true
- name: Display update report
run: cat update_report.txt
- name: Create issue if updates available
if: steps.check.outputs.exit_code == '1' && github.event_name == 'schedule'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const report = fs.readFileSync('update_report.txt', 'utf8');
// Extract summary from report
const summaryMatch = report.match(/📊 Summary:.*?\n((?: • .*\n)+)/s);
const updates = summaryMatch ? summaryMatch[1].trim() : 'See workflow run for details';
// Check if there's already an open issue
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'dependencies,conan'
});
const existingIssue = issues.data.find(issue =>
issue.title.includes('Conan package updates available')
);
const body = "## Conan Package Updates Available\n\n" +
"The weekly dependency check has found updates for Conan packages:\n\n" +
updates + "\n\n" +
"### How to Update\n\n" +
"To update a specific package:\n" +
"```bash\n" +
"python scripts/check_conan_updates.py --update --package PACKAGE_NAME\n" +
"```\n\n" +
"To update all packages:\n" +
"```bash\n" +
"python scripts/check_conan_updates.py --update\n" +
"```\n\n" +
"### Full Report\n" +
"<details>\n" +
"<summary>Click to expand</summary>\n\n" +
"```\n" +
report + "\n" +
"```\n" +
"</details>\n\n" +
"---\n" +
"*This issue was automatically created by the [Check Conan Dependencies workflow](" +
context.serverUrl + "/" + context.repo.owner + "/" + context.repo.repo + "/actions/runs/" + context.runId + ").*";
if (existingIssue) {
// Update existing issue
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: "## Updated Report (" + new Date().toISOString().split('T')[0] + ")\n\n" + body
});
console.log('Updated existing issue #' + existingIssue.number);
} else {
// Create new issue
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Conan package updates available',
body: body,
labels: ['dependencies', 'conan']
});
console.log('Created new issue for Conan updates');
}
- name: Upload report as artifact
if: always()
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: conan-update-report
path: update_report.txt
retention-days: 30