Skip to content

test: cover weekly issue update helpers #1177

test: cover weekly issue update helpers

test: cover weekly issue update helpers #1177

name: First Interaction

Check warning on line 1 in .github/workflows/first.interaction.yml

View workflow run for this annotation

GitHub Actions / First Interaction

Workflow execution policy warning (evaluate mode)

On December 2, 2026, GitHub will restrict `pull_request_target` on public repositories by default. To continue allowing the event trigger, configure an Actions policy. Learn more: https://gh.io/securely-using-pull_request_target#default-policy-for-pull_request_target
on:
issues:
types: [opened]
pull_request_target:
types: [opened]
jobs:
greet:
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
issues: write
pull-requests: write
steps:
- name: Greet First-Time Contributor
uses: actions/github-script@v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const creator = context.payload.sender.login;
const owner = context.repo.owner;
const repo = context.repo.repo;
const number = context.issue.number;
const isPR = !!context.payload.pull_request;
const typeQuery = isPR ? 'is:pr' : 'is:issue';
// Find this author's earliest issue/PR of this type in the repo (#216).
// The search API's default sort is undocumented "best match" with no
// guaranteed order for a query with no free-text terms - it happens to
// come back newest-first today, but that's not a contract, so pin it
// explicitly to sort=created&order=asc. With that, the single oldest
// result answers "is this their first?" directly - no need to guess
// how many of their recent contributions might fit in a top-N page.
const query = `repo:${owner}/${repo} ${typeQuery} author:${creator}`;
const result = await github.rest.search.issuesAndPullRequests({
q: query,
sort: 'created',
order: 'asc',
per_page: 1,
});
// If their earliest match isn't this one, they've contributed before.
const earliest = result.data.items[0];
const hasPrior = !!earliest && earliest.number < number;
if (!hasPrior) {
const issueMsg = `Hey @${creator}, thanks for raising this. I really appreciate it.\n\nFair Code exists because bias in AI has real consequences for real people, so every issue matters here, whether it's a bug, a dataset question, or something that just didn't feel right. We'll take a look and get back to you.\n\nIn the meantime, feel free to explore the [live audits](https://www.thefaircode.xyz) or check the [contributing guide](CONTRIBUTING.md) if you want to dig deeper.`;
const prMsg = `Hey @${creator}, your first PR on Fair Code, that's awesome, thank you.\n\nThis project is about making AI more accountable, and contributions like yours are what keep that work going. We'll review your changes shortly.\n\nIf you haven't already, give the [contributing guide](CONTRIBUTING.md) a quick read: it covers how audits are structured and what we look for in a review.\n\nAnd if you're finding Fair Code useful or interesting, a star on the repo genuinely helps more people find it - no pressure, just appreciated.`;
await github.rest.issues.createComment({
owner,
repo,
issue_number: number,
body: isPR ? prMsg : issueMsg
});
}