New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom Pr_number after merge to master not working #282
Comments
It was a problem to get PR number after merge in master with push event. Found this way, it works well. Thanks! |
Here's a working snippet to get the issue number in both steps:
- uses: actions/github-script@v6
id: get_issue_number
with:
script: |
if (context.issue.number) {
// Return issue number if present
return context.issue.number;
} else {
// Otherwise return issue number from commit
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0].number;
}
result-encoding: string
- name: Issue number
run: echo '${{steps.get_issue_number.outputs.result}}' The script queries the list labels for an issue REST API endpoint via octokit/rest.js client. |
If anyone is wondering how to get a complete, yet working, yml file, here it is: name: 'Your awesome new GA'
on:
push:
branches:
- main
jobs:
pr-number:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: read
steps:
- uses: actions/github-script@v7
id: get_pr_data
with:
script: |
return (
await github.rest.repos.listPullRequestsAssociatedWithCommit({
commit_sha: context.sha,
owner: context.repo.owner,
repo: context.repo.repo,
})
).data[0];
- name: Pull Request data
run: |
echo '${{ fromJson(steps.get_pr_data.outputs.result).number }}'
echo '${{ fromJson(steps.get_pr_data.outputs.result).title }}' Please notice that both permissions ( |
Hello!
I have got simple workflow:
After merge to master, I need to post commit on PR, which was merged to master. In action log I see, that it's now pr_number env:
Is any ideas, why pr_number did not set?
Thank you!
The text was updated successfully, but these errors were encountered: