Skip to content

Commit 4b2f882

Browse files
xmulliganjoestringer
authored andcommitted
Create reusable-greetings.yml
I want to set up a action to greet new contributors. I've borrowed from https://github.com/kubestellar/infra/blob/main/.github/workflows/reusable-greetings.yml Fixes the git history from cilium#45527 Signed-off-by: Bill Mulligan <billmulligan516@gmail.com>
1 parent c9929f8 commit 4b2f882

3 files changed

Lines changed: 120 additions & 0 deletions

File tree

.github/workflows/greetings.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Greetings
2+
3+
on:
4+
pull_request_target:
5+
types: [opened]
6+
issues:
7+
types: [opened]
8+
9+
permissions:
10+
contents: read
11+
issues: write
12+
pull-requests: write
13+
14+
jobs:
15+
greet:
16+
# Only enforce on drive-by / first-time contributors.
17+
# Regulars (MEMBER, COLLABORATOR, OWNER, CONTRIBUTOR) are skipped entirely.
18+
if: >
19+
github.event.pull_request.author_association == 'FIRST_TIME_CONTRIBUTOR' ||
20+
github.event.pull_request.author_association == 'FIRST_TIMER' ||
21+
github.event.pull_request.author_association == 'NONE'
22+
uses: cilium/cilium/.github/workflows/reusable-greetings.yml@main
23+
secrets: inherit
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
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');

CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,7 @@
277277
/.github/workflows/conformance-kind-proxy-embedded.yaml @cilium/sig-servicemesh @cilium/github-sec @cilium/ci-structure
278278
/.github/workflows/scale-test-egw.yaml @cilium/egress-gateway @cilium/sig-scalability @cilium/github-sec @cilium/ci-structure
279279
/.github/workflows/tests-ces-migrate.yaml @cilium/sig-scalability @cilium/github-sec @cilium/ci-structure
280+
/.github/workflows/*reusable-greetings*.yml @cilium/github-sec @cilium/community
280281
/.gitignore @cilium/contributing
281282
/.golangci.yaml @cilium/ci-structure
282283
/.mailmap @cilium/release-managers

0 commit comments

Comments
 (0)