diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f4180dc..1e37d04 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 }}" diff --git a/README.md b/README.md index c10daac..5488336 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/action.yml b/action.yml index 263f8c7..cae4b81 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/index.js b/index.js index c80171a..4b5445a 100644 --- a/index.js +++ b/index.js @@ -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));