added use of personal token

This commit is contained in:
amd64fox 2025-03-07 13:36:57 +03:00
parent 446cc5327b
commit 9ecfee6004
3 changed files with 21 additions and 5 deletions

View file

@ -8,12 +8,14 @@ on:
jobs:
check-and-update:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
token: ${{ secrets.PERSONAL_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
@ -27,5 +29,6 @@ jobs:
- name: Run version checker
env:
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
PERSONAL_TOKEN: ${{ secrets.PERSONAL_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: python check_deb_versions.py

View file

@ -12,10 +12,14 @@ on:
jobs:
update-version:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.PERSONAL_TOKEN }}
- name: Set up Python
uses: actions/setup-python@v5
@ -33,4 +37,4 @@ jobs:
git config --local user.name "GitHub Action"
git add versions.json
git commit -m "Added version ${{ github.event.inputs.version }}"
git push
git push "https://${{ secrets.PERSONAL_TOKEN }}@github.com/${{ github.repository }}.git" HEAD:main

View file

@ -127,9 +127,18 @@ def commit_changes(new_versions):
else:
commit_message = "Update Spotify versions"
# Создаем коммит и отправляем изменения
# Создаем коммит
subprocess.run(["git", "commit", "-m", commit_message])
subprocess.run(["git", "push"])
if github_actions:
token = get_github_token()
if token:
repo_url = f"https://{token}@github.com/{os.environ.get('GITHUB_REPOSITORY')}.git"
subprocess.run(["git", "push", repo_url, "HEAD:main"])
else:
subprocess.run(["git", "push"])
else:
subprocess.run(["git", "push"])
print("Изменения успешно отправлены в репозиторий.")
return True