Skip to content

Commit

Permalink
chore(vercel): build ignore settings (#285)
Browse files Browse the repository at this point in the history
# Feature

Dev. 🐧

## What does this PR do?

- Ignore build under certain conditions
  - Only build for main, preview, and develop branches
  - Only build if the commit does not include .md files

## Before submitting

> [!WARNING]
>
> The following is allowed for review only. (No additions or
modifications are permitted.)

- [x] I have read the [Contribution
Guidelines](https://github.com/iputapp/lounas/blob/develop/.github/CONTRIBUTING.md).
- [x] I agree to the [Code of
Conduct](https://github.com/iputapp/lounas/blob/develop/.github/CODE_OF_CONDUCT.md).
  • Loading branch information
wiyco authored Jun 9, 2024
2 parents df03e19 + b0b5dc5 commit d91b8b3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 10 deletions.
24 changes: 14 additions & 10 deletions vercel-build-ignore.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
#!/bin/bash

echo "VERCEL_GIT_COMMIT_REF: $VERCEL_GIT_COMMIT_REF"

if [[ "$VERCEL_GIT_COMMIT_REF" == "develop" || "$VERCEL_GIT_COMMIT_REF" == "preview" || "$VERCEL_GIT_COMMIT_REF" == "main" ]] ; then
# Proceed with the build
echo "βœ… - Build can proceed"
exit 1;
# Only build for main, preview, and develop branches
BRANCH=$(git rev-parse --abbrev-ref HEAD)
if [ "$BRANCH" != "main" ] && [ "$BRANCH" != "preview" ] && [ "$BRANCH" != "develop" ]; then
echo "πŸ›‘ Skipping build for branch $BRANCH"
exit 0
fi

else
# Don't build
echo "πŸ›‘ - Build cancelled"
exit 0;
# Only build if the commit does not include .md files
if git diff --name-only HEAD~1 HEAD | grep -q '\.md$'; then
echo "πŸ›‘ Skipping build because commit includes .md files"
exit 0
fi

# Proceed with the build
echo "βœ… Proceeding with the build"
exit 1
3 changes: 3 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignoreCommand": "bash vercel-build-ignore.sh"
}

0 comments on commit d91b8b3

Please sign in to comment.