|
| 1 | +name: 'First time contributor' |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened] |
| 6 | + |
| 7 | +jobs: |
| 8 | + welcome_first_contributor: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + if: github.event.pull_request.author_association == 'NONE' |
| 11 | + steps: |
| 12 | + - name: Add label and welcome comment with DCO check |
| 13 | + uses: actions/github-script@v7 |
| 14 | + with: |
| 15 | + script: | |
| 16 | + // Add label |
| 17 | + await github.rest.issues.addLabels({ |
| 18 | + owner: context.repo.owner, |
| 19 | + repo: context.repo.repo, |
| 20 | + issue_number: context.issue.number, |
| 21 | + labels: ['first-time contributor'] |
| 22 | + }); |
| 23 | +
|
| 24 | + // Check DCO |
| 25 | + const { data: commits } = await github.rest.pulls.listCommits({ |
| 26 | + owner: context.repo.owner, |
| 27 | + repo: context.repo.repo, |
| 28 | + pull_number: context.issue.number |
| 29 | + }); |
| 30 | +
|
| 31 | + const hasDCO = commits.every(commit => |
| 32 | + commit.commit.message.includes('Signed-off-by:') |
| 33 | + ); |
| 34 | +
|
| 35 | + const dcoMessage = hasDCO |
| 36 | + ? '' |
| 37 | + : '\n\n Please sign your commits or look the DCO.'; |
| 38 | +
|
| 39 | + // Post comment |
| 40 | + await github.rest.issues.createComment({ |
| 41 | + owner: context.repo.owner, |
| 42 | + repo: context.repo.repo, |
| 43 | + issue_number: context.issue.number, |
| 44 | + body: `Welcome, New contributor! Thank you for submitting your PR on Score-Compose.${dcoMessage}\n\nPlease review our Contributing Guidelines [here](https://github.com/score-spec/score-compose/blob/main/CONTRIBUTING.md).\n\nA maintainer will review your pull request soon. Thank you for helping make Score better ♥️!` |
| 45 | + }); |
0 commit comments