-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(chromatic): allow to run on both master and other branches (#2006)
- Loading branch information
1 parent
db2e085
commit fd6500e
Showing
3 changed files
with
78 additions
and
14 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
name: Check Changed Packages | ||
description: Check if there are any changed packages in the monorepo | ||
|
||
inputs: | ||
exit_on_no_changes: | ||
description: Whether to exit with a non-zero code if there are no changes. | ||
required: false | ||
default: "false" | ||
outputs: | ||
has_changes: | ||
description: Whether there are any changes in the monorepo. | ||
value: ${{ steps.check-changed-packages.outputs.has_changes }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- id: determine-since-flag | ||
uses: ./.github/actions/determine-lerna-since-flag | ||
- id: check-changed-packages | ||
shell: bash | ||
env: | ||
SINCE_FLAG: ${{ steps.determine-since-flag.outputs.since_flag }} | ||
run: | | ||
changed_packages=$(yarn -s lerna ls $SINCE_FLAG --json --loglevel=error) | ||
if [[ $changed_packages = "[]" ]]; then | ||
echo "has_changes=false" >> $GITHUB_OUTPUT | ||
echo "No packages to process as Lerna didn't detect any changes." | ||
if [[ "${{ inputs.exit_on_no_changes }}" == "true" ]]; then | ||
exit 1 | ||
else | ||
echo "Continuing because exit_on_no_changes is not used." | ||
fi | ||
else | ||
echo "has_changes=true" >> $GITHUB_OUTPUT | ||
echo "Change detected:" | ||
echo "$changed_packages" | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Determine Lerna since flag | ||
description: Determine the --since flag value for Lerna commands based on the branch. Should be used for workflows/actions that can be used on both default branch and other branches. | ||
|
||
outputs: | ||
since_flag: | ||
description: The --since flag value to use with Lerna commands. | ||
value: ${{ steps.get-since-flag.outputs.since_flag }} | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- id: get-since-flag | ||
shell: bash | ||
run: | | ||
if [[ "$GITHUB_REF" == "refs/heads/master" ]]; then | ||
since_flag="--since" | ||
echo "Running on master branch, checking for all changes." | ||
else | ||
since_flag="--since=origin/master" | ||
echo "Not running on master branch, checking for changes since origin/master." | ||
fi | ||
echo "since_flag=$since_flag" >> $GITHUB_OUTPUT |
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