feat: Added workflow for better Recognize/Credit Contributors #3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Credits upon opening PR | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
update-credits: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Update Credits | |
run: | | |
contributor_name=$(jq -r '.pull_request.user.login' $GITHUB_EVENT_PATH) | |
pr_description=$(jq -r '.pull_request.body' $GITHUB_EVENT_PATH) | |
echo "### Timestamp:" >> .github/credits.md | |
echo "$(date -u +"%Y-%m-%dT%H:%M:%SZ")" >> .github/credits.md | |
echo "### Contributor:" >> .github/credits.md | |
echo "${{ github.event.pull_request.user.login }}" >> .github/credits.md | |
echo "#### PR Title:" >> .github/credits.md | |
echo "${{ github.event.pull_request.title }}" >> .github/credits.md | |
echo "############################################" >> .github/credits.md | |
git add .github/credits.md | |
git config --local user.email "action@github.com" | |
git config --local user.name "GitHub Action" | |
git commit -m "Update credits.md with contributor information" || exit 0 | |
git push origin ${{ github.event.pull_request.head.ref }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |