From 4d91f5fc49ab9405423688f2ebbbe368c4143c8e Mon Sep 17 00:00:00 2001 From: Helder Oliveira Date: Mon, 2 Sep 2024 13:44:22 +0100 Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20changeset=20status=20re?= =?UTF-8?q?cursive=20and=20regex=20pattern=20match?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workflows/changeset-version-management.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/changeset-version-management.yml b/.github/workflows/changeset-version-management.yml index c7728db..c987369 100644 --- a/.github/workflows/changeset-version-management.yml +++ b/.github/workflows/changeset-version-management.yml @@ -65,16 +65,25 @@ jobs: # Default skip state skip="false" # Changeset artifacts - changesetArtifactsPath=".changeset" + changesetArtifactsRegex="\.changeset/.*\.md$" # Commit hash that triggered workflow commitHash="${{ github.sha }}" + + diffTree=$(git diff-tree --no-commit-id --name-only -r "$commitHash") + + if [[ -n "$diffTree" ]]; then + echo "⚠️ The diff command found:" + echo "$diffTree" + else + echo "⚠️ The diff result is empty!" + fi # If no changes found, skip - if ! git diff-tree --no-commit-id --name-only "$commitHash" | grep -q "$changesetArtifactsPath"; then + if echo "$diffTree" | grep -qE "$changesetArtifactsRegex"; then + echo "✅ Changeset found!" + else echo "⚠️ Warning: The .changeset directory doesn't have new changesets, should skip!" skip="true" - else - echo "✅ Changset found!" fi echo "skip=$skip" >> "$GITHUB_OUTPUT"