Skip to content

Update PRs

Update PRs #1604

Workflow file for this run

---
# Copyright 2016-present Thomas Leplus
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
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.debug(JSON.stringify(pr))
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.debug(JSON.stringify(result))
core.info(JSON.stringify(result.data))
}).catch(function(error) {
core.error(error)
})
}