|
| 1 | +name: External contributor greeter |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request_target: |
| 5 | + types: |
| 6 | + - opened |
| 7 | + - reopened |
| 8 | + |
| 9 | +env: |
| 10 | + ORGANIZATION: Ethereum |
| 11 | + DRY_RUN: false |
| 12 | + |
| 13 | +jobs: |
| 14 | + comment-external-pr: |
| 15 | + runs-on: ubuntu-latest |
| 16 | + steps: |
| 17 | + - name: Get organization members |
| 18 | + id: get_members |
| 19 | + env: |
| 20 | + GH_TOKEN: ${{ secrets.READ_ORG }} |
| 21 | + CONTRIBUTOR: ${{ github.event.pull_request.user.login }} |
| 22 | + run: | |
| 23 | + gh api graphql \ |
| 24 | + --raw-field organization="$ORGANIZATION" \ |
| 25 | + --raw-field query=' |
| 26 | + query($organization: String!, $cursor: String) { |
| 27 | + organization(login: $organization) { |
| 28 | + membersWithRole(first: 100, after: $cursor) { |
| 29 | + pageInfo { |
| 30 | + hasNextPage, |
| 31 | + endCursor |
| 32 | + } |
| 33 | + nodes { |
| 34 | + login |
| 35 | + } |
| 36 | + } |
| 37 | + } |
| 38 | + }' > org_members.json |
| 39 | + echo "CONTRIBUTOR_IS_ORG_MEMBER=$( |
| 40 | + jq \ |
| 41 | + --arg contributor $CONTRIBUTOR \ |
| 42 | + '.data.organization.membersWithRole | any(.nodes[].login; . == $contributor)' \ |
| 43 | + org_members.json |
| 44 | + )" >> $GITHUB_OUTPUT |
| 45 | +
|
| 46 | + - name: Comment on external contribution PR |
| 47 | + if: ${{ steps.get_members.outputs.CONTRIBUTOR_IS_ORG_MEMBER == 'false' }} |
| 48 | + env: |
| 49 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 50 | + PR: ${{ github.event.pull_request.html_url }} |
| 51 | + run: | |
| 52 | + echo "Commenting in a newly submitted or reopened external PR: $PR" |
| 53 | + if [[ $DRY_RUN == 'false' ]]; then |
| 54 | + gh pr edit "$PR" --add-label "external contribution :star:" |
| 55 | + comment_body=( |
| 56 | + "Thank you for your contribution to the Solidity compiler! A team member will follow up shortly." |
| 57 | + "\n\n" |
| 58 | + "If you haven't read our [contributing guidelines](https://docs.soliditylang.org/en/latest/contributing.html) and our " |
| 59 | + "[review checklist](https://github.com/ethereum/solidity/blob/develop/ReviewChecklist.md) before, " |
| 60 | + "please do it now, this makes the reviewing process and accepting your contribution smoother." |
| 61 | + "\n\n" |
| 62 | + "If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the " |
| 63 | + "[#solidity-dev](https://matrix.to/#/#ethereum_solidity-dev:gitter.im) channel on Matrix." |
| 64 | + ) |
| 65 | + gh pr comment $PR --body "$(IFS='' ; echo -e "${comment_body[*]}")" |
| 66 | + fi |
0 commit comments