From e0a0402b1b5bf80e58fb45eb61b0a8d3fc24ff90 Mon Sep 17 00:00:00 2001 From: Kumaran Rajendhiran Date: Fri, 15 Nov 2024 11:23:37 +0530 Subject: [PATCH] Add pre-commit to check app name registered or not --- .../.pre-commit-config.yaml | 10 ++++++++++ .../scripts/check-registered-app-pre-commit.sh | 13 +++++++++++++ .../scripts/check-registered-app.sh | 8 ++++++++ 3 files changed, 31 insertions(+) create mode 100755 {{cookiecutter.project_slug}}/scripts/check-registered-app-pre-commit.sh create mode 100755 {{cookiecutter.project_slug}}/scripts/check-registered-app.sh diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index dbbeff8..3c32927 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -36,3 +36,13 @@ repos: hooks: - id: detect-secrets args: ["--baseline", ".secrets.baseline"] + + - repo: local + hooks: + - id: check-registered-app + name: Check if the app name is registered in fly.io + entry: "scripts/check-registered-app-pre-commit.sh" + language: python + types: [python] + require_serial: true + verbose: true diff --git a/{{cookiecutter.project_slug}}/scripts/check-registered-app-pre-commit.sh b/{{cookiecutter.project_slug}}/scripts/check-registered-app-pre-commit.sh new file mode 100755 index 0000000..5f2aef8 --- /dev/null +++ b/{{cookiecutter.project_slug}}/scripts/check-registered-app-pre-commit.sh @@ -0,0 +1,13 @@ +#!/usr/bin/env bash + +# taken from: https://jaredkhan.com/blog/mypy-pre-commit + +# A script for running mypy, +# with all its dependencies installed. + +set -o errexit + +# Change directory to the project root directory. +cd "$(dirname "$0")"/.. + +./scripts/check-registered-app.sh diff --git a/{{cookiecutter.project_slug}}/scripts/check-registered-app.sh b/{{cookiecutter.project_slug}}/scripts/check-registered-app.sh new file mode 100755 index 0000000..62a816e --- /dev/null +++ b/{{cookiecutter.project_slug}}/scripts/check-registered-app.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +# Check file registered_app_domain.txt exists. If it does not exists, echo and exit. +if [ ! -f registered_app_domain.txt ]; then + echo -e "\033[0;33mWarning: App name is not registered.\033[0m" + echo -e "\033[0;33mGithub Actions may fail if you push without registering.\033[0m" + echo -e "\033[0;33mRegister your app name by running the script 'scripts/register_to_fly_io.sh'.\033[0m" +fi