Skip to content

Instantly share code, notes, and snippets.

@JustDevZero
Last active May 20, 2021 21:10
Show Gist options
  • Save JustDevZero/1c02427031b3a58c2bcd2db715c38c14 to your computer and use it in GitHub Desktop.
Save JustDevZero/1c02427031b3a58c2bcd2db715c38c14 to your computer and use it in GitHub Desktop.
autoguess
import json
from os import getenv
try:
GITHUB_CONTEXT = json.loads(getenv('GITHUB_CONTEXT', b'{}').decode())
except BaseException:
GITHUB_CONTEXT = json.loads(getenv('GITHUB_CONTEXT', '{}'))
EVENT = GITHUB_CONTEXT.get('event', {})
COMMITS = EVENT.get('commits', [])
LINES = '\n'.join([x.get('message') for x in COMMITS])
result = 'patch'
if 'fix' in LINES or 'bug' in LINES:
result = 'minor'
if 'feat' in LINES or 'refactor' in LINES:
result = 'major'
print(result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment