Skip to content

Commit

Permalink
feat: include pre-push githook to build project
Browse files Browse the repository at this point in the history
  • Loading branch information
augusto-draxx committed Feb 25, 2025
1 parent c24907f commit 3b496c3
Showing 1 changed file with 27 additions and 17 deletions.
44 changes: 27 additions & 17 deletions .githooks/pre-push/pre-push
Original file line number Diff line number Diff line change
@@ -1,17 +1,27 @@
#!/bin/bash

source "$PWD"/common/shell/colors.sh
source "$PWD"/common/shell/ascii.sh

while read local_ref local_sha remote_ref remote_sha; do
if [[ "$local_ref" =~ ^refs/heads/ ]]; then
branch_name=$(echo "$local_ref" | sed 's|^refs/heads/||')

if [[ ! "$branch_name" =~ ^(feature|fix|hotfix|docs|refactor|build|test)/.*$ ]]; then
echo "${bold}Branch names must start with 'feature/', 'fix/', 'refactor/', 'docs/', 'test/' or 'hotfix/' followed by either a task id or feature name."
exit 1
fi
fi
done

exit 0
#!/bin/bash

source "$PWD"/common/shell/colors.sh
source "$PWD"/common/shell/ascii.sh

while read local_ref local_sha remote_ref remote_sha; do
if [[ "$local_ref" =~ ^refs/heads/ ]]; then
branch_name=$(echo "$local_ref" | sed 's|^refs/heads/||')

if [[ ! "$branch_name" =~ ^(feature|fix|hotfix|docs|refactor|build|test)/.*$ ]]; then
echo "${bold}Branch names must start with 'feature/', 'fix/', 'refactor/', 'docs/', 'test/' or 'hotfix/' followed by either a task id or feature name."
exit 1
fi
fi
done

echo "${bold}Running project build (npm run build)...${normal}"

npm run build
if [ $? -ne 0 ]; then
echo "${bold}Build failed. The push will be cancelled.${normal}"
exit 1
fi

echo "${bold}Build successful. Continuing with the push...${normal}"

exit 0

0 comments on commit 3b496c3

Please sign in to comment.