-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
33 lines (33 loc) · 1.14 KB
/
action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Get PR Info
outputs:
pr-info:
description: String encoded JSON object containing pull-request information
value: ${{ steps.get-pull-request.outputs.result }}
runs:
using: composite
steps:
- uses: actions/github-script@v7
id: get-pull-request
with:
retries: 3
script: |
return (
await github.rest.pulls.get({
repo: context.repo.repo,
owner: context.repo.owner,
pull_number: (() => {
switch('${{ github.event_name }}') {
case 'pull_request':
case 'pull_request_target':
return '${{ github.ref }}'.split('/')[2];
case 'push':
const branch = '${{ github.ref_name }}';
if (!branch.match(new RegExp('^pull-request/[0-9]+$'))) {
throw new Error(`${branch} does not match PR branch pattern.`);
}
return branch.split('/')[1];
}
throw new Error(`Could not determine pull request number.`);
})()
})
).data;