Monitor upstream SDKs #23
This file contains hidden or 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: Monitor upstream SDKs | |
| on: | |
| schedule: | |
| - cron: '0 6 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| check-updates: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| issues: write | |
| contents: read | |
| steps: | |
| - name: Check upstream repositories | |
| id: check | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const repos = [ | |
| { owner: 'togethercomputer', repo: 'together-python' }, | |
| { owner: 'togethercomputer', repo: 'together-typescript' } | |
| ]; | |
| const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000); | |
| const results = []; | |
| for (const target of repos) { | |
| const { data } = await github.repos.listCommits({ owner: target.owner, repo: target.repo, per_page: 10 }); | |
| const recent = data.filter(c => new Date(c.commit.committer.date) > cutoff); | |
| if (recent.length > 0) { | |
| results.push({ | |
| owner: target.owner, | |
| repo: target.repo, | |
| commits: recent.map(c => ({ | |
| sha: c.sha.substring(0, 7), | |
| message: c.commit.message.split('\n')[0], | |
| url: c.html_url, | |
| date: c.commit.committer.date | |
| })) | |
| }); | |
| } | |
| } | |
| core.setOutput('updates', JSON.stringify(results)); | |
| core.info(`Found ${results.length} repositories with updates.`); | |
| - name: Create tracking issue | |
| if: steps.check.outputs.updates != '[]' | |
| uses: actions/github-script@v7 | |
| env: | |
| UPDATES: ${{ steps.check.outputs.updates }} | |
| with: | |
| script: | | |
| const updates = JSON.parse(process.env.UPDATES ?? '[]'); | |
| const today = new Date().toISOString().split('T')[0]; | |
| let body = 'Detected new upstream commits:\n\n'; | |
| for (const repo of updates) { | |
| body += `### ${repo.owner}/${repo.repo}\n`; | |
| for (const commit of repo.commits) { | |
| body += `- [${commit.sha}](${commit.url}) ${commit.message} (_${commit.date}_)\n`; | |
| } | |
| body += '\n'; | |
| } | |
| await github.issues.create({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| title: `Upstream SDK updates ${today}`, | |
| body, | |
| labels: ['upstream-monitor'] | |
| }); | |
| - name: No updates found | |
| if: steps.check.outputs.updates == '[]' | |
| run: echo "No upstream changes detected in the last 24 hours." |