|
| 1 | +name: Reusable Greetings |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + pr_message: |
| 7 | + description: 'Message to post for PR contributors' |
| 8 | + required: false |
| 9 | + type: string |
| 10 | + default: | |
| 11 | + 👋 Welcome to the Cilium community! 🐝 Thanks and congrats for opening your first PR here. We're excited to have you contributing! |
| 12 | +
|
| 13 | + **Before we can merge, please ensure:** |
| 14 | + - ✅ **You've Gone Through** every step of the [pull request template](https://github.com/cilium/cilium/blob/main/.github/pull_request_template.md) and have it in your PR |
| 15 | + - ✅ **You've Read** [Submitting a pull request](https://docs.cilium.io/en/stable/contributing/development/contributing_guide/#submitting-a-pull-request) |
| 16 | +
|
| 17 | + 📬 If you're using Cilium in your organization, please [add your name to our Adopters list](https://github.com/cilium/cilium/blob/main/USERS.md). 🙏 It really helps the project gain momentum and credibility. |
| 18 | +
|
| 19 | + **Resources:** |
| 20 | + - Attend the [weekly Cilium community meeting](https://docs.cilium.io/en/stable/community/community/#weekly-community-meeting) to join the development conversation |
| 21 | + - If you are new to eBPF, you can learn more on our community website: https://ebpf.io 🐝 |
| 22 | + - If you are new to Cilium, we have great [getting started guides](https://docs.cilium.io/en/stable/#getting-started) |
| 23 | + - Subscribe to eCHO News for your bi-weekly [Cilium and eBPF update](https://cilium.io/newsletter/) |
| 24 | + - [Slack](https://docs.cilium.io/en/stable/community/community/#slack) is the best place to start conversation. |
| 25 | + - Get hands on learning with interactive [courses and labs](https://cilium.io/labs/categories/getting-started/) |
| 26 | +
|
| 27 | + issue_message: |
| 28 | + description: 'Message to post for issue creators' |
| 29 | + required: false |
| 30 | + type: string |
| 31 | + default: | |
| 32 | + 👋 Welcome to the Cilium and eBPF community! 🐝 Thanks for helping to make Cilium better by reporting this issue. Please make sure the issue you are reporting is for a [maintained stable release](https://github.com/cilium/cilium/#stable-releases) and review the [triage process](https://docs.cilium.io/en/latest/contributing/development/reviewers_committers/triage/) to understand how the project works through issues. |
| 33 | +
|
| 34 | + 📬 If you're using Cilium in your organization, please [add your name to our Adopters list](https://github.com/cilium/cilium/blob/main/USERS.md). 🙏 It really helps the project gain momentum and credibility. |
| 35 | +
|
| 36 | + **Resources:** |
| 37 | + - If you are new to eBPF, you can learn more on our community website: https://ebpf.io 🐝 |
| 38 | + - If you are new to Cilium, we have great [getting started guides](https://docs.cilium.io/en/stable/#getting-started) |
| 39 | + - Subscribe to eCHO News for your bi-weekly [Cilium and eBPF update](https://cilium.io/newsletter/) |
| 40 | + - [Slack](https://docs.cilium.io/en/stable/community/community/#slack) is the best place to start conversation. |
| 41 | + - Get hands on learning with interactive [courses and labs](https://cilium.io/labs/categories/getting-started/) |
| 42 | + - To get Cilium enterprise support or for other matters, see the [enterprise page](https://cilium.io/enterprise/) |
| 43 | +
|
| 44 | +permissions: |
| 45 | + contents: read |
| 46 | + |
| 47 | +jobs: |
| 48 | + greeting: |
| 49 | + runs-on: ubuntu-latest |
| 50 | + permissions: |
| 51 | + issues: write |
| 52 | + pull-requests: write |
| 53 | + steps: |
| 54 | + - name: Greet contributor |
| 55 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 56 | + env: |
| 57 | + PR_MESSAGE: ${{ inputs.pr_message }} |
| 58 | + ISSUE_MESSAGE: ${{ inputs.issue_message }} |
| 59 | + with: |
| 60 | + script: | |
| 61 | + const { owner, repo } = context.repo; |
| 62 | + const author = context.payload.pull_request?.user?.login || context.payload.issue?.user?.login; |
| 63 | + const isPR = !!context.payload.pull_request; |
| 64 | + const itemNumber = context.payload.pull_request?.number || context.payload.issue?.number; |
| 65 | +
|
| 66 | + if (!author || !itemNumber) { |
| 67 | + console.log('Could not determine author or item number'); |
| 68 | + return; |
| 69 | + } |
| 70 | +
|
| 71 | + // Skip bots |
| 72 | + if (author.endsWith('[bot]') || author === 'dependabot' || author === 'github-actions') { |
| 73 | + console.log(`Skipping bot: ${author}`); |
| 74 | + return; |
| 75 | + } |
| 76 | +
|
| 77 | + // Check if this is the author's first issue/PR in this repo |
| 78 | + const searchType = isPR ? 'pr' : 'issue'; |
| 79 | + const query = `repo:${owner}/${repo} author:${author} type:${searchType}`; |
| 80 | + const { data: searchResult } = await github.rest.search.issuesAndPullRequests({ q: query, per_page: 2 }); |
| 81 | + if (searchResult.total_count > 1) { |
| 82 | + console.log(`${author} already has ${searchResult.total_count} ${searchType}s — skipping greeting`); |
| 83 | + return; |
| 84 | + } |
| 85 | +
|
| 86 | + console.log(`First-time greeting for ${author} on ${isPR ? 'PR' : 'issue'} #${itemNumber}`); |
| 87 | +
|
| 88 | + const message = isPR ? process.env.PR_MESSAGE : process.env.ISSUE_MESSAGE; |
| 89 | + await github.rest.issues.createComment({ |
| 90 | + owner, |
| 91 | + repo, |
| 92 | + issue_number: itemNumber, |
| 93 | + body: message |
| 94 | + }); |
| 95 | +
|
| 96 | + console.log('Greeting posted successfully'); |
0 commit comments