diff --git a/.github/workflows/commit-user-records.yml b/.github/workflows/commit-user-records.yml new file mode 100644 index 0000000..891893d --- /dev/null +++ b/.github/workflows/commit-user-records.yml @@ -0,0 +1,58 @@ +name: Commit User Records + +on: + push: + branches: + - main # or your default branch + workflow_dispatch: + +jobs: + commit: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.9' + + - name: Install dependencies + run: | + pip install PyGithub + + - name: Commit and push user records + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + python -c " +import os +import json +from github import Github + +# GitHub repository details +GITHUB_REPO_OWNER = 'ChrisTitusTech' +GITHUB_REPO_NAME = 'WinUtil' +FILE_PATH = 'user_records.json' + +# Load user records (simulate here, you may use actual logic) +user_records = {'example_user_id': {'github_username': 'example_user', 'contributions': 'some_status'}} + +# Convert user records to JSON +file_content = json.dumps(user_records, indent=4) + +# Initialize GitHub client +g = Github(os.getenv('GITHUB_TOKEN')) +repo = g.get_repo(f'{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}') + +# Update or create file in the repository +try: + file = repo.get_contents(FILE_PATH) + repo.update_file(file.path, 'Update user records', file_content, file.sha) +except: + repo.create_file(FILE_PATH, 'Create user records file', file_content) + +print('User records committed successfully.') +" diff --git a/user_records.json b/user_records.json new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/user_records.json @@ -0,0 +1 @@ +