Skip to content

adding code.json

adding code.json #2

Workflow file for this run

name: Update Contributors Information
on:
workflow_dispatch: {}
push:
branches: [main]
jobs:
update-contributors:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if update needed
id: check_changes
env:
{% raw %}

Check failure on line 24 in .github/workflows/contributors.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/contributors.yml

Invalid workflow file

You have an error in your yaml syntax on line 24
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
{% endraw %}
run: |
OWNER=$(echo $GITHUB_REPOSITORY | cut -d'/' -f1)
REPO=$(echo $GITHUB_REPOSITORY | cut -d'/' -f2)
CURRENT=$(gh api \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
"/repos/$OWNER/$REPO/contributors?per_page=100" | \
jq -r '[.[] | select(.type != "Bot" and (.login | test("\\[bot\\]$") | not) and (.login | test("-bot$") | not)) | .login] | sort | join(",")')
EXISTING=$(grep -oP '(?<=github.com/)[^"]+(?=">)' COMMUNITY.md | \
grep -v "^$" | sort | uniq | tr '\n' ',' | sed 's/,$//')
echo "Current contributors: $CURRENT"
echo "Existing contributors: $EXISTING"
if [ "$CURRENT" = "$EXISTING" ]; then
echo "has_changes=false" >> $GITHUB_OUTPUT
echo "No new contributors found. Skipping update!"
else
echo "has_changes=true" >> $GITHUB_OUTPUT
echo "New contributors detected. Running update!"
fi
- name: Update contributor list
if: steps.check_changes.outputs.has_changes == 'true'
id: update_contributors
uses: akhilmhdh/contributors-readme-action@v2.3.10
env:
{% raw %}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
{% endraw %}
with:
readme_path: COMMUNITY.md
commit_message: "updating contributors list"
pr_title_on_protected: "docs: update contributors information"
committer_username: "github-actions[bot]"
committer_email: "github-actions[bot]@users.noreply.github.com"
- name: Update PR
if: steps.check_changes.outputs.has_changes == 'true' && steps.update_contributors.outputs.pr_id != ''
env:
{% raw %}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
{% endraw %}
run: |
{% raw %}
PR_NUMBER="${{ steps.update_contributors.outputs.pr_id }}"
{% endraw %}
gh pr edit $PR_NUMBER \
--body "New contributors detected! This PR updates the contributors list in COMMUNITY.md." \
--add-label "documentation"