Feat: Add GitHub token verification script and integrate it into workflow
Test Python CLI / test (push) Successful in 11s

This commit is contained in:
2026-08-24 09:24:29 +02:00
parent 1ab8c20f6b
commit dbea784721
3 changed files with 41 additions and 0 deletions
+3
View File
@@ -19,6 +19,9 @@ jobs:
with:
python-version: '3.14'
- name: Check Authentication
run: python3 python/check_github_token.py "${{ secrets.GH_TOKEN }}"
- name: Go ACME Setup
run: python3 python/install_github_release.py go-acme/lego -t archive -k "${{ secrets.GH_TOKEN }}" -p /tmp/python-cli-test
+3
View File
@@ -19,6 +19,9 @@ jobs:
with:
python-version: '3.14'
- name: Check Authentication
run: python3 python/check_github_token.py "${{ github.token }}"
- name: Go ACME Setup
run: python3 python/install_github_release.py go-acme/lego -t archive -k "${{ github.token }}" -p /tmp/python-cli-test
+35
View File
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
import argparse
import os
import sys
from install_github_release import fetch_latest_release
def main():
"""Parse command-line arguments and verify a GitHub token, reporting errors via the exit code."""
parser = argparse.ArgumentParser(
usage='%(prog)s [token]',
allow_abbrev=False,
)
parser.add_argument('token', nargs='?', help='The GitHub token to verify')
args = parser.parse_args()
token = args.token or os.environ.get('GITHUB_TOKEN')
if not token:
print('Error: No GitHub token provided as an argument or found in GITHUB_TOKEN environment variable.', file=sys.stderr)
sys.exit(1)
print('Verifying GitHub token...')
try:
fetch_latest_release('actions/checkout', token)
print('\x1b[32mSuccess: The provided GitHub token is valid and has sufficient permissions to access public repositories.\x1b[0m')
except Exception as error:
print('\x1b[31mError: GitHub token verification failed.\x1b[0m', file=sys.stderr)
print(f'Reason: {error}', file=sys.stderr)
sys.exit(1)
if __name__ == '__main__':
main()