diff --git a/.github/scripts/welcomeScript.js b/.github/scripts/welcomeScript.js new file mode 100644 index 00000000..72a54337 --- /dev/null +++ b/.github/scripts/welcomeScript.js @@ -0,0 +1,59 @@ +module.exports = async ({ github, context }) => { + const owner = context.repo.owner; + const repo = context.repo.repo; + const issueNumber = context.issue.number; + const eventName = context.eventName; + const ghUsername = context.payload.sender.login; + + try { + const issueAssociation = + context.payload.issue?.author_association; + + if ( + eventName === 'issues' && + issueAssociation === 'FIRST_TIMER' + ) { + return await github.rest.issues.createComment({ + owner, + repo, + issue_number: issueNumber, + body: `👋 Thanks for opening your first issue, @${ghUsername}! + +We appreciate your contribution and are excited to have you here. Please make sure to follow the contribution guidelines and provide as much detail as possible. + +To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community: +https://discord.gg/QueQN83wn + +Looking forward to collaborating with you!` + }); + } + + const prAssociation = + context.payload.pull_request?.author_association; + + if ( + eventName === 'pull_request_target' && + ( + prAssociation === 'FIRST_TIMER' || + prAssociation === 'FIRST_TIME_CONTRIBUTOR' + ) + ) { + return await github.rest.issues.createComment({ + owner, + repo, + issue_number: issueNumber, + body: `🎉 Thanks for your first contribution, @${ghUsername}! + +We're excited to have you here. A maintainer will review your PR soon. Please check CI results and review any feedback if needed. + +To stay updated, ask questions, and connect with maintainers and contributors, please join our Discord community: +https://discord.gg/QueQN83wn + +Looking forward to collaborating with you!` + }); + } + + } catch (error) { + console.error(error); + } +}; \ No newline at end of file diff --git a/.github/workflows/unassign-unlinked-issues.yml b/.github/workflows/unassign-unlinked-issues.yml index 3ef74082..40bcab5f 100644 --- a/.github/workflows/unassign-unlinked-issues.yml +++ b/.github/workflows/unassign-unlinked-issues.yml @@ -12,6 +12,9 @@ jobs: issues: write steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + - name: Unassign issues with no linked PR and notify uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 #v9.0.0 with: diff --git a/.github/workflows/welcome-first-time.yml b/.github/workflows/welcome-first-time.yml new file mode 100644 index 00000000..2f3acc4e --- /dev/null +++ b/.github/workflows/welcome-first-time.yml @@ -0,0 +1,27 @@ +name: Welcome First-Time Contributors + +on: + issues: + types: [opened] + pull_request_target: + types: [opened] + +permissions: + issues: write + pull-requests: write + +jobs: + welcome: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd #v6.0.2 + + - name: Welcome first-time contributor + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const script = require('./.github/scripts/welcomeScript.js'); + await script({ github, context }); \ No newline at end of file