Add version management dashboard

This commit is contained in:
minchulahn
2023-08-11 12:17:05 +09:00
parent 88240959e3
commit 00f7e27697
7 changed files with 212 additions and 1 deletions

57
dashboard/settings.py Normal file
View File

@@ -0,0 +1,57 @@
import json, requests, os
from git import Repo
repo = Repo('.')
file_path = './version.json'
repo.config_writer().set_value('user', 'name', 'dsk-minchulahn').release()
repo.config_writer().set_value('user', 'email', 'minchulahn@ex-em.com').release()
def get_datasaker():
return json.load(open(file_path, 'r'))['datasaker']
def get_service():
return json.load(open(file_path, 'r'))['service']
def get_commit_id():
return repo.head.commit
def get_tags():
return repo.tags
def diff():
if len(repo.index.diff(repo.head.commit)) > 0:
return True
return False
def diff_remote_head():
repo.remote().fetch()
remote_head = repo.remote().refs['main'].commit
if repo.head.commit == remote_head:
return True
else:
return False
def git_pull():
repo.remote().fetch()
repo.remotes.origin.pull()
def git_push(commit_message, extended_description):
repo.git.add('version.json')
if len(repo.index.diff(repo.head.commit)) > 0:
repo.index.commit(f'{commit_message}\n\n{extended_description}')
repo.git.push(force=False)
def publish_release(selected_tag, release_title, release_describe):
api_url = 'https://api.github.com/repos/cloudmoa/sample-app/releases'
github_token = os.environ.get('GITHUB_TOKEN')
headers = {'Authorization': f'Bearer {github_token}', 'Accept': 'application/vnd.github.v3+json'}
release_data = {
'tag_name': selected_tag,
'name': release_title,
'body': release_describe,
'draft': False,
'prerelease': False
}
return requests.post(api_url, json=release_data, headers=headers)