Skip to content
name: 'Notify about seated PRs'
on:
schedule:
- cron: '0 6 * * *'
push:
branches:
- 28718-notify-seated-prs
jobs:
notify-about-prs:
runs-on: ubuntu-22.04
env:
REPO: core
steps:
- run: echo 'GitHub context'
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
- id: fetch-seated-prs
name: Fetch PRs
uses: actions/github-script@v7
with:
result-encoding: string
retries: 3
retry-exempt-status-codes: 400,401
github-token: ${{ secrets.CI_MACHINE_TOKEN }}
script: |
const fetch = require('fetch')
consta headers = {
'Accept': 'application/vnd.github+json'
'Authorization': 'Bearer ${{ secrets.GITHUB_TOKEN }}'
'X-GitHub-Api-Version': '2022-11-28'
};
async function fetchOpenPrs() {
const response = fetch(
'https://api.github.com/repos/${{ github.repository_owner }}/${{ env.REPO }}/pulls?per_page=100',
{
headers,
});
}
async function fetchOpenPrs2() {
const opts = github.rest.pulls.get.endpoint.merge({
...{
baseUrl: 'https://api.github.com/repos/${{ github.repository_owner }}/${{ env.REPO }}/pulls',
owner: '${{ github.repository_owner }}',
repo: '${{ env.REPO }}',
per_page: 100
}
});
console.log('OJO:>> ' + JSON.stringify(opts, null, 2));
const response = github.paginate(github.rest.pulls.get, opts);
console.log('OJO:>> ' + JSON.stringify(response, null, 2));
return response.data;
}
const prs = await fetchOpenPrs();
console.log(`PRs: ${prs.length}`);
console.log(JSON.stringify(prs, null, 2));