From 0fe8d9fbc215f4a1d00884f4d393b38036cd0503 Mon Sep 17 00:00:00 2001 From: Thomas Leplus Date: Sat, 11 May 2024 23:04:07 -0400 Subject: [PATCH] Schedule workflows --- .github/workflows/update-prs.yml | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 .github/workflows/update-prs.yml diff --git a/.github/workflows/update-prs.yml b/.github/workflows/update-prs.yml new file mode 100644 index 0000000..2082e34 --- /dev/null +++ b/.github/workflows/update-prs.yml @@ -0,0 +1,41 @@ +--- +name: Update PRs + +on: + push: + schedule: + - cron: '0 * * * *' + workflow_dispatch: + +permissions: + pull-requests: write + contents: write + +jobs: + update: + if: startsWith(github.ref, 'refs/heads/') + runs-on: ubuntu-latest + steps: + - name: Update Pull Requests + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + script: | + const opts = github.rest.pulls.list.endpoint.merge({ + owner: context.repo.owner, + repo: context.repo.repo, + state: 'open', + base: context.ref.replace('refs/heads/', ''), + }) + const prs = await github.paginate(opts) + for (const pr of prs) { + core.info(`Updating PR #${pr.number}`) + github.rest.pulls.updateBranch({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: pr.number, + }).then(function(result) { + core.info(JSON.stringify(result.data)) + }).catch(function(error) { + core.error(error) + }) + }