Skip to content

Commit

Permalink
feat: add contributor pr open comment action
Browse files Browse the repository at this point in the history
  • Loading branch information
yoonhyejin committed Sep 27, 2024
1 parent f8dd1a6 commit 148d6c7
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/contributor-open-pr-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR Merge Comment

on:
pull_request:
types: [opened]

jobs:
post-pr-opened-comment:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Get and Format Username (PR only)
if: github.event_name == 'pull_request'
run: |
formatted_username=$(echo "${{ github.event.pull_request.user.login }}" | tr '[:upper:]' '[:lower:]' | sed 's/ /-/g')
echo "FORMATTED_USERNAME=$formatted_username" >> $GITHUB_ENV
- name: Create Comment (PR only)
if: github.event_name == 'pull_request'
uses: actions/github-script@v6
with:
script: |
if (context.payload.pull_request) {
const prUser = process.env.FORMATTED_USERNAME;
const url = `https://datahub-contributor-cards.vercel.app/${prUser}`;
const body = `![Image](https://datahub-contributor-cards.vercel.app/api/og?userId=${{ github.event.pull_request.user.login }})\n\n Hello @${prUser} :smile: \n\n Thank you so much for opening a pull request!\nYou can check out your contributor card and see all your past stats here: [${url}](${url})`;
// Create a comment on the PR
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body: body
});
} else {
console.log('Not a pull request event.');
}

0 comments on commit 148d6c7

Please sign in to comment.