forked from metaplex-foundation/metaplex-program-library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
38 lines (34 loc) · 1.18 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
34
35
36
37
38
name: 'Get pull_request number for commit, if any'
description: 'Returns pull_request number or -1 if no pull_request associated with commit'
inputs:
commit-sha:
description: 'Commit SHA'
required: true
outputs:
pull-number:
description: Pull request number
value: ${{ steps.set-output.outputs.pull-number }}
runs:
using: 'composite'
steps:
- uses: actions/checkout@v3
- name: Fetch pull_request data associated with commit SHA
uses: actions/github-script@v4
id: fetch-pull-number-for-commit
# assummption: we only care about the latest PR associated with the commit?
with:
script: |
const { data } = await github.request(
"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls",
{
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: '${{ inputs.commit-sha }}'
})
return data.length === 0 ? -1 : data[data.length-1].number
- name: Set output
id: set-output
run: echo "::set-output name=pull-number::$PR_NUMBER"
shell: bash
env:
PR_NUMBER: ${{ steps.fetch-pull-number-for-commit.outputs.result }}