Created
October 20, 2021 03:52
-
-
Save dmattia/79c475202758e01e15f71b152c8ffde1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
WORKSPACE="${WORKSPACE:-@main/main}" | |
echo "Finding dependencies to watch under $WORKSPACE..." | |
watchedDependencies=$(yarn info "$WORKSPACE" --all --recursive --dependents --json | jq ".children.Dependencies[].locator, .value" | grep '@workspace' | sed 's/.*@workspace://' | sed 's/"$//' | xargs echo) | |
echo "Dependencies being watched: $watchedDependencies" | |
echo "" | |
echo "Finding dependencies that changed..." | |
changedDependencies=$(yarn workspaces list --json --since | jq ".location" | grep -v '\.' | xargs echo) | |
echo "Dependencies that changed: $changedDependencies" | |
echo "" | |
echo "Finding which watched deps have changed..." | |
has_changed=false | |
for changedLocation in $watchedDependencies; do | |
for depLocation in $changedDependencies; do | |
if [ "$changedLocation" == "$depLocation" ]; then | |
echo "The dependency $changedLocation changed in this pull request" | |
has_changed=true | |
fi | |
done | |
done | |
echo "" | |
if [[ -z "$GITHUB_ACTIONS" ]]; then | |
echo "dependencies of $WORKSPACE changed: $has_changed" | |
else | |
echo "::set-output name=has_changed::$has_changed" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment