@@ -67,20 +67,26 @@ jobs:
67
67
68
68
# Add "First-time Contributor" label if PR is from a first-time contributor:
69
69
- name : ' Add "First-time Contributor" label if PR is from a first-time contributor'
70
- if : ${{ ( github.event.action == 'opened' || github.event.action == 'reopened' ) && github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR ' }}
70
+ if : ${{ github.event.action == 'opened' || github.event.action == 'reopened' }}
71
71
# Pin action to full-length commit SHA
72
72
uses : actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
73
73
with :
74
74
github-token : ${{ secrets.CHATBOT_GITHUB_TOKEN }}
75
75
script : |
76
- const labels = context.payload.pull_request.labels.map( label => label.name );
77
- if ( !labels.includes( 'First-time Contributor' ) ) {
78
- await github.rest.issues.addLabels({
79
- 'owner': context.repo.owner,
80
- 'repo': context.repo.repo,
81
- 'issue_number': context.payload.pull_request.number,
82
- 'labels': [ 'First-time Contributor' ]
83
- });
76
+ const { data: pr } = await github.rest.pulls.get({
77
+ 'owner': context.repo.owner,
78
+ 'repo': context.repo.repo,
79
+ 'pull_number': context.payload.pull_request.number
80
+ });
81
+ if ( pr.author_association === 'FIRST_TIME_CONTRIBUTOR' ) {
82
+ const labels = context.payload.pull_request.labels.map( label => label.name );
83
+ if ( !labels.includes( 'First-time Contributor' ) ) {
84
+ await github.rest.issues.addLabels({
85
+ 'owner': context.repo.owner,
86
+ 'repo': context.repo.repo,
87
+ 'issue_number': context.payload.pull_request.number,
88
+ 'labels': [ 'First-time Contributor' ]
89
+ });
84
90
}
85
91
86
92
# Add "Needs Review" label when PR is opened and not a draft:
0 commit comments