mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-29 12:06:44 +00:00
Make versions_check more reliable in forks (#7785)
* discover repo only run in GH actions use discovered api this is usefull for GHES enviroments style fixes * Fix wrong env name
This commit is contained in:
parent
32db71cabb
commit
6f67fb2c9a
17
.github/scripts/version_check.py
vendored
17
.github/scripts/version_check.py
vendored
@ -18,6 +18,9 @@ from pathlib import Path
|
|||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
REPO = os.getenv('GITHUB_REPOSITORY', 'inventree/inventree')
|
||||||
|
GITHUB_API_URL = os.getenv('GITHUB_API_URL', 'https://api.github.com')
|
||||||
|
|
||||||
|
|
||||||
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."""
|
||||||
@ -28,9 +31,7 @@ def get_existing_release_tags():
|
|||||||
if token:
|
if token:
|
||||||
headers = {'Authorization': f'Bearer {token}'}
|
headers = {'Authorization': f'Bearer {token}'}
|
||||||
|
|
||||||
response = requests.get(
|
response = requests.get(f'{GITHUB_API_URL}/repos/{REPO}/releases', headers=headers)
|
||||||
'https://api.github.com/repos/inventree/inventree/releases', headers=headers
|
|
||||||
)
|
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
@ -90,6 +91,11 @@ def check_version_number(version_string, allow_duplicate=False):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
# Ensure that we are running in GH Actions
|
||||||
|
if os.environ.get('GITHUB_ACTIONS', '') != 'true':
|
||||||
|
print('This script is intended to be run within a GitHub Action!')
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
if 'only_version' in sys.argv:
|
if 'only_version' in sys.argv:
|
||||||
here = Path(__file__).parent.absolute()
|
here = Path(__file__).parent.absolute()
|
||||||
version_file = here.joinpath(
|
version_file = here.joinpath(
|
||||||
@ -102,14 +108,13 @@ if __name__ == '__main__':
|
|||||||
results[0] = str(int(results[0]) - 1)
|
results[0] = str(int(results[0]) - 1)
|
||||||
print(results[0])
|
print(results[0])
|
||||||
exit(0)
|
exit(0)
|
||||||
|
|
||||||
# GITHUB_REF_TYPE may be either 'branch' or 'tag'
|
# GITHUB_REF_TYPE may be either 'branch' or 'tag'
|
||||||
GITHUB_REF_TYPE = os.environ['GITHUB_REF_TYPE']
|
GITHUB_REF_TYPE = os.environ['GITHUB_REF_TYPE']
|
||||||
|
|
||||||
# GITHUB_REF may be either 'refs/heads/<branch>' or 'refs/heads/<tag>'
|
# GITHUB_REF may be either 'refs/heads/<branch>' or 'refs/heads/<tag>'
|
||||||
GITHUB_REF = os.environ['GITHUB_REF']
|
GITHUB_REF = os.environ['GITHUB_REF']
|
||||||
|
|
||||||
GITHUB_REF_NAME = os.environ['GITHUB_REF_NAME']
|
GITHUB_REF_NAME = os.environ['GITHUB_REF_NAME']
|
||||||
|
|
||||||
GITHUB_BASE_REF = os.environ['GITHUB_BASE_REF']
|
GITHUB_BASE_REF = os.environ['GITHUB_BASE_REF']
|
||||||
|
|
||||||
# Print out version information, makes debugging actions *much* easier!
|
# Print out version information, makes debugging actions *much* easier!
|
||||||
@ -193,7 +198,7 @@ if __name__ == '__main__':
|
|||||||
# Ref: https://getridbug.com/python/how-to-set-environment-variables-in-github-actions-using-python/
|
# Ref: https://getridbug.com/python/how-to-set-environment-variables-in-github-actions-using-python/
|
||||||
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
|
with open(os.getenv('GITHUB_ENV'), 'a') as env_file:
|
||||||
# Construct tag string
|
# Construct tag string
|
||||||
tags = ','.join([f'inventree/inventree:{tag}' for tag in docker_tags])
|
tags = ','.join([f'{REPO}:{tag}' for tag in docker_tags])
|
||||||
|
|
||||||
env_file.write(f'docker_tags={tags}\n')
|
env_file.write(f'docker_tags={tags}\n')
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user