Automate prow job dispatcher at Fri, 28 Feb 2025 11:40:25 UTC #16
Workflow file for this run
This file contains 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: Auto Merge dispatcher PR | |
permissions: write-all | |
on: | |
pull_request: | |
types: [opened, edited, reopened, synchronize] | |
jobs: | |
auto-merge: | |
if: ${{ startsWith(github.event.pull_request.title, 'Automate prow job dispatcher at') && github.event.pull_request.user.login == 'openshift-bot' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Merge PR | |
uses: actions/github-script@v6 | |
env: | |
GITHUB_TOKEN: ${{ secrets.MERGE_TOKEN }} | |
with: | |
script: | | |
const prNumber = context.payload.pull_request.number; | |
console.log(`Attempting to merge PR #${prNumber}...`); | |
try { | |
const mergeResponse = await github.rest.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: prNumber, | |
merge_method: "squash" | |
}); | |
console.log('Merge successful:', mergeResponse.data); | |
} catch (error) { | |
console.error('Failed to merge PR:', error); | |
throw error; | |
} | |