Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/contributor-card-comment.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: PR Comment

on:
pull_request_target:
types: [opened]
Comment on lines +4 to +5

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using unsafe GitHub Actions trigger may allow privilege escalation via CI/CD - high severity
Using pull_request_target or workflow_run as a trigger is not recommended, as it may allow an attacker to elevate its privileges via the CI/CD pipeline by exfiltrating secrets (e.g. by reading out the caches of the GitHub Actions pipeline or listing loaded secrets in the environment). If the affected repository is open source, the attacker doesn't have to be an insider but could be any GitHub user.

Remediation: Avoid using pull_request_target or workflow_run as a trigger.
View details in Aikido Security


permissions:
pull-requests: write

jobs:
post-pr-opened-comment:
runs-on: ubuntu-latest
steps:
- name: Get and Format Username
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
uses: actions/github-script@v8
with:
script: |
const prUser = process.env.FORMATTED_USERNAME;
const prLogin = context.payload.pull_request.user.login;
const url = `https://contributors.datahubproject.io/${prUser}`;
const body = `Hello @${prLogin} :smile: \n\n Thank you so much for opening a pull request!\n\n![Image](https://contributors.datahubproject.io/api/og?userId=${prLogin})\nYou can check out your contributor card and see all your past stats [here](${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
});
42 changes: 0 additions & 42 deletions .github/workflows/contributor-open-pr-comment.yml

This file was deleted.

Loading