name: Update Organization Members

on:
  schedule:
    - cron: '0 0 * * *'
  push:
      branches:
          - main
  workflow_dispatch:

permissions:
  contents: write

jobs:
  update-readme:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install Dependencies
        run: pip install requests

      - name: Update Members Script
        env:
          GH_TOKEN: ${{ secrets.ORG_READ_TOKEN }} 
          ORG_NAME: ${{ github.repository_owner }}
        run: python scripts/update_members.py

      - name: Commit and Push Changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: "docs: update organization members list"
          branch: main
          file_pattern: "profile/README.md"
