Skip to content

This is an old pull request #68

This is an old pull request

This is an old pull request #68

name: update-contributor-details
on:
pull_request_target:
types: [closed]
branches: [main]
jobs:
update-by-pr:
if: |
github.event.pull_request.merged == true &&
!contains(github.event.pull_request.title, 'maintenance') &&
!contains(github.event.pull_request.title, 'Maintenance')
runs-on: ubuntu-latest
permissions:
contents: write
env:
REPO_NAME: ${{ github.repository }}
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Checking out the repo
uses: actions/checkout@v4.1.0
- name: Setup Python
uses: actions/setup-python@v4.7.1
with:
python-version: 3.12
- name: Getting PR details
run: |
touch pr.json
gh pr view $PR_NUMBER --json author,url,files > pr.json
cat pr.json
env:
GH_TOKEN: ${{ github.token }}
- name: Pull any new changes
run: git pull origin main
- name: Updating log file
run: |
if [ ! -d ".github/data" ]; then
mkdir .github/data
echo "Create `.github/data` directory"
fi
python .github/scripts/update_contributors_log.py
git diff .github/data/contributors-log.json
- name: Updating index.md file
run: |
python .github/scripts/update_index_md.py
git diff index.md
- name: Remove unwanted files
run: rm pr.json
- name: Commit and Push
run: |
if [ "$(git status | grep 'Changes not staged\|Untracked files')" ]; then
echo "::group::Printing All Diffs"
git diff
echo "::endgroup::"
echo "::group::Configuring GitHub Action as author"
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git config --list | cat
echo "::endgroup::"
echo "::group::Adding and Pushing Changes"
git add .
git commit -m "Updated Contributors Details"
git push origin main
echo "Pushed the update successfully"
echo "::endgroup::"
else
echo "::error::No Changes detected!"
exit 1
fi