name: Publish TPTP Test Report as Discussion on: push: branches: - copilot/test-copilot-integration workflow_dispatch: inputs: category: description: 'Discussion category name' required: false default: 'Agentic Workflows' type: string permissions: discussions: write contents: read jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 with: ref: copilot/test-copilot-integration - name: Create GitHub Discussion uses: actions/github-script@v7 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | const fs = require('fs'); // Read the master-branch report (preferred) or fall back to older report let body; const candidates = ['tptp-test-report-master.md', 'tptp-test-report.md']; let reportFile = null; for (const f of candidates) { if (fs.existsSync(f)) { reportFile = f; break; } } if (!reportFile) { core.setFailed('No TPTP report file found'); return; } try { body = fs.readFileSync(reportFile, 'utf8'); } catch (e) { core.setFailed('Could not read report: ' + e.message); return; } console.log('Using report file:', reportFile); // Get discussion category ID const categoryName = context.eventName === 'workflow_dispatch' ? (context.payload.inputs && context.payload.inputs.category) || 'Agentic Workflows' : 'Agentic Workflows'; const catQuery = await github.graphql(` query($owner: String!, $name: String!) { repository(owner: $owner, name: $name) { id discussionCategories(first: 20) { nodes { id name slug } } } } `, { owner: context.repo.owner, name: context.repo.repo }); const cats = catQuery.repository.discussionCategories.nodes; console.log('Available categories:', cats.map(c => c.name)); let cat = cats.find(c => c.name === categoryName); if (!cat) { cat = cats.find(c => c.name.toLowerCase().includes('general')) || cats.find(c => c.name.toLowerCase().includes('show')) || cats[0]; console.log(`Category "${categoryName}" not found, using: ${cat && cat.name}`); } if (!cat) { core.setFailed('No discussion category found'); return; } const repoNodeId = catQuery.repository.id; const title = 'TPTP Test Report \u2014 master branch re-run after #9483 merge'; // Check if a discussion with this title already exists const existingQuery = await github.graphql(` query($owner: String!, $name: String!, $q: String!) { search(query: $q, type: DISCUSSION, first: 5) { nodes { ... on Discussion { id title url } } } } `, { owner: context.repo.owner, name: context.repo.repo, q: \`repo:\${context.repo.owner}/\${context.repo.repo} "\${title}"\` }); const existing = existingQuery.search.nodes.find(d => d.title === title); if (existing) { console.log('Discussion already exists:', existing.url); core.summary.addRaw(\`## Discussion Already Exists\n\n[\${existing.url}](\${existing.url})\`); await core.summary.write(); return; } const result = await github.graphql(` mutation($input: CreateDiscussionInput!) { createDiscussion(input: $input) { discussion { url title } } } `, { input: { repositoryId: repoNodeId, categoryId: cat.id, title: title, body: body } }); const url = result.createDiscussion.discussion.url; console.log('Discussion created:', url); core.summary.addRaw(\`## Discussion Created\n\n[\${url}](\${url})\`); await core.summary.write();