mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
Use github token for version check (#4092)
* Use github token for version check - Should prevent 403 errors * Use github token when running version update in unit test
This commit is contained in:
parent
17b0399d26
commit
4034349043
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@ -9,6 +9,8 @@ jobs:
|
|||||||
|
|
||||||
stable:
|
stable:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # pin@v3.1.0
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import os
|
||||||
import re
|
import re
|
||||||
import warnings
|
import warnings
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
@ -338,7 +339,16 @@ def check_for_updates():
|
|||||||
logger.info("Could not perform 'check_for_updates' - App registry not ready")
|
logger.info("Could not perform 'check_for_updates' - App registry not ready")
|
||||||
return
|
return
|
||||||
|
|
||||||
response = requests.get('https://api.github.com/repos/inventree/inventree/releases/latest')
|
headers = {}
|
||||||
|
|
||||||
|
# If running within github actions, use authentication token
|
||||||
|
if settings.TESTING:
|
||||||
|
token = os.getenv('GITHUB_TOKEN', None)
|
||||||
|
|
||||||
|
if token:
|
||||||
|
headers['Authorization'] = f"Bearer {token}"
|
||||||
|
|
||||||
|
response = requests.get('https://api.github.com/repos/inventree/inventree/releases/latest', headers=headers)
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise ValueError(f'Unexpected status code from GitHub API: {response.status_code}') # pragma: no cover
|
raise ValueError(f'Unexpected status code from GitHub API: {response.status_code}') # pragma: no cover
|
||||||
|
@ -21,7 +21,16 @@ import requests
|
|||||||
def get_existing_release_tags():
|
def get_existing_release_tags():
|
||||||
"""Request information on existing releases via the GitHub API"""
|
"""Request information on existing releases via the GitHub API"""
|
||||||
|
|
||||||
response = requests.get('https://api.github.com/repos/inventree/inventree/releases')
|
# Check for github token
|
||||||
|
token = os.getenv('GITHUB_TOKEN', None)
|
||||||
|
headers = None
|
||||||
|
|
||||||
|
if token:
|
||||||
|
headers = {
|
||||||
|
"Authorization": f"Bearer {token}"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.get('https://api.github.com/repos/inventree/inventree/releases', headers=headers)
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise ValueError(f'Unexpected status code from GitHub API: {response.status_code}')
|
raise ValueError(f'Unexpected status code from GitHub API: {response.status_code}')
|
||||||
|
Loading…
Reference in New Issue
Block a user