Skip to content

Commit

Permalink
Merge pull request #28 from rYuuk/master
Browse files Browse the repository at this point in the history
Add PR Labels
  • Loading branch information
8BitJonny authored Mar 3, 2022
2 parents 0a46d94 + c22457b commit e5776e6
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ jobs:
echo "The PR Created_At is ${{ steps.getPR.outputs.pr_created_at }}"
echo "The PR Merged_At is ${{ steps.getPR.outputs.pr_merged_at }}"
echo "The PR Closed_At is ${{ steps.getPR.outputs.pr_closed_at }}"
echo "The PR Labels are ${{ steps.getPR.outputs.pr_labels }}"
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,11 @@ This action enables you to get the PR no matter which event type triggered the w
prCreatedAt: ${{ steps.PR.outputs.pr_created_at }}
prMergedAt: ${{ steps.PR.outputs.pr_merged_at }}
prClosedAt: ${{ steps.PR.outputs.pr_closed_at }}
prLabel: ${{ steps.PR.outputs.pr_labels }}
```

### Pull_request trigger
If you use the `pull_request` event trigger, it won't find the assosiated PR for the first commit inside that same PR out of the box.
If you use the `pull_request` event trigger, it won't find the associated PR for the first commit inside that same PR out of the box.

This [article](https://frontside.com/blog/2020-05-26-github-actions-pull_request/#how-does-pull_request-affect-actionscheckout) describes why this is, in detail.
A short form of the article's explanation is, that Github creates an extra merge commit before the `pull_request` event is triggered for which this action can't find an assosiated PR. The `pull_request` trigger for the second PR commit and all following, will again work as expected.
Expand Down
2 changes: 2 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ outputs:
description: The PR Merged timestamp if one was found.
pr_closed_at:
description: The PR Closed timestamp if one was found.
pr_labels:
description: The PR Labels if any was found.
runs:
using: node12
main: 'index.js'
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ async function main() {
setOutput('pr_created_at', pr ? pr.created_at : '');
setOutput('pr_merged_at', pr ? pr.merged_at : '');
setOutput('pr_closed_at', pr ? pr.closed_at : '');
setOutput('pr_labels', pr ? pr.labels.map(e => e.name).join(",") : '');
}

main().catch(err => setFailed(err.message));

0 comments on commit e5776e6

Please sign in to comment.