File organizer #15
Workflow file for this run
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-contributor-details | |
on: | |
pull_request_target: | |
types: [closed] | |
branches: [main] | |
env: | |
REPO_NAME: ${{ github.repository }} | |
PR_NUMBER: ${{ github.event.pull_request.number }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
update-by-pr: | |
if: ${{ github.event.pull_request.title != 'init' && github.event.pull_request.merged == true }} | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checking out the repo | |
uses: actions/[email protected] | |
- name: Setup Python | |
uses: actions/[email protected] | |
- name: Getting PR details | |
run: | | |
touch pr.json | |
gh pr view $PR_NUMBER --json author,url,files > pr.json | |
- 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 | |
cat .github/data/contributors-log.json | |
- name: Updating index.md file | |
run: | | |
python .github/scripts/update_index_md.py | |
cat 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 | |
git diff | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add . | |
git commit -m "Updated Contributors Details" | |
git push origin main | |
echo "Pushed the update successfully" | |
else | |
echo "Nothing to push" | |
exit 1 | |
fi |