Skip to content

test again

test again #4

Workflow file for this run

on:
push:
branches:
- main
- 4-proj-automatically-generate-a-contributors-list-in-maintainersmd-file
workflow_dispatch:
jobs:
update-contributors:
runs-on: ubuntu-latest
name: Update contributors info in MAINTAINERS.md
permissions:
contents: write
pull-requests: write
steps:
# Update contributor list
- name: Contribute List
uses: akhilmhdh/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
# https://github.com/marketplace/actions/contribute-list#optional-parameters
readme_path: MAINTAINERS.md
use_username: false
commit_message: "BOT: Update contributors info in MAINTAINERS.md"
# Update contributor count
- name: Checkout repository
uses: actions/checkout@v4
- name: Get repository contributors count
id: get_contributors
run: |
REPO_OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
REPO_NAME=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
CONTRIBUTORS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/$REPO_OWNER/$REPO_NAME/contributors?per_page=100" | jq '. | length')
echo "Total contributors: $CONTRIBUTORS"
echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT
- name: Replace slug in MAINTAINERS.md with number of contributors
run: |
CONTRIBUTORS=${{ steps.get_contributors.outputs.contributors }}
sed -i 's/<!--CONTRIBUTOR COUNT START-->.*<!--CONTRIBUTOR COUNT END-->/<!--CONTRIBUTOR COUNT START--> '"$CONTRIBUTORS"' <!--CONTRIBUTOR COUNT END-->/g' MAINTAINERS.md
- name: Commit and push changes
# commit changes, but if no changes exist, then exit cleanly
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
git pull
git add MAINTAINERS.md
git commit -m "BOT: Update contributors info in MAINTAINERS.md" || exit 0
git push