Last active
November 28, 2022 20:20
-
-
Save naesheim/18d0c0a58ee61f4674353a2f4cf71475 to your computer and use it in GitHub Desktop.
CircleCi - only build features that has changed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## | |
### config.yml ### | |
################## | |
version: 2 | |
jobs: | |
build: | |
docker: | |
- image: circleci/python:3.6 | |
steps: | |
- checkout | |
- run: | |
command: | | |
.circleci/commit_check.sh | |
####################### | |
### commit_check.sh ### | |
####################### | |
set -e | |
# latest commit | |
LATEST_COMMIT=$(git rev-parse HEAD) | |
# latest commit where path/to/folder1 was changed | |
FOLDER1_COMMIT=$(git log -1 --format=format:%H --full-diff path/to/folder1) | |
# latest commit where path/to/folder2 was changed | |
FOLDER2_COMMIT=$(git log -1 --format=format:%H --full-diff path/to/folder2) | |
if [ $FOLDER1_COMMIT = $LATEST_COMMIT ]; | |
then | |
echo "files in folder1 has changed" | |
.circleci/do_something.sh | |
elif [ $FOLDER2_COMMIT = $LATEST_COMMIT ]; | |
then | |
echo "files in folder2 has changed" | |
.circleci/do_something_else.sh | |
else | |
echo "no folders of relevance has changed" | |
exit 0; | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i get the same ^