diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index 76146e3..0656329 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -30,3 +30,11 @@ pass_filenames: false always_run: true minimum_pre_commit_version: '0.19.0' +- id: sbt-github-actions + name: Generate github workflows using sbt-github-actions plugin + language: python_venv + stages: [commit,push] + entry: sbt-github-actions + pass_filenames: false + always_run: true + minimum_pre_commit_version: '0.19.0' diff --git a/pre_commit_hooks/sbt_github_actions.py b/pre_commit_hooks/sbt_github_actions.py new file mode 100644 index 0000000..fd2d2c5 --- /dev/null +++ b/pre_commit_hooks/sbt_github_actions.py @@ -0,0 +1,15 @@ +from pre_commit_hooks.runner import run_sbt_command +from colorama import init as colorama_init, Fore + +SBT_TASK = 'githubWorkflowGenerate' +MISSING_PLUGIN_CHECK_STRING = f'Not a valid key: {SBT_TASK}' +MISSING_PLUGIN_ERROR_MSG = f'{Fore.RED}ERROR: sbt-github-actions SBT plugin not present! See {Fore.BLUE}https://github.com/djspiewak/sbt-github-actions#sbt-github-actions{Fore.RED} for installation instructions.' + + +def main(argv=None): + colorama_init() + return run_sbt_command(f'; clean ; {SBT_TASK}', MISSING_PLUGIN_CHECK_STRING, MISSING_PLUGIN_ERROR_MSG) + + +if __name__ == '__main__': + exit(main()) diff --git a/setup.cfg b/setup.cfg index 9e198a3..dbef588 100644 --- a/setup.cfg +++ b/setup.cfg @@ -13,3 +13,4 @@ console_scripts = sbt-wartremover = pre_commit_hooks.sbt_wartremover:main scalafmt = pre_commit_hooks.scalafmt:main sbt-fatal-warnings = pre_commit_hooks.sbt_fatal_warnings:main + sbt-github-actions = pre_commit_hooks.sbt_github_actions:main