Skip to content

Commit 558dadd

Browse files
committed
feat: add turbo to track shared package changes
1 parent c59cc99 commit 558dadd

4 files changed

Lines changed: 191 additions & 13 deletions

File tree

.github/workflows/deploy-base.yml

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -67,25 +67,45 @@ jobs:
6767
with:
6868
fetch-depth: 2
6969

70+
- name: Set up Node.js
71+
if: inputs.target == ''
72+
uses: actions/setup-node@v4
73+
with:
74+
node-version: '20'
75+
76+
- name: Cache node_modules
77+
if: inputs.target == ''
78+
uses: actions/cache@v4
79+
with:
80+
path: node_modules
81+
key: deploy-node-modules-${{ runner.os }}-node20-${{ hashFiles('package-lock.json') }}
82+
83+
- name: Install dependencies
84+
if: inputs.target == ''
85+
run: npm ci
86+
7087
- name: Detect Build Target
7188
id: detect_targets
7289
run: |
7390
if [ -n "${{ inputs.target }}" ]; then
7491
echo "Using provided target: ${{ inputs.target }}"
75-
TARGETS="${{ inputs.target }}"
76-
else
77-
echo "Detecting targets from git diff..."
78-
TARGETS=$(git diff --name-only HEAD~1..HEAD | grep '^apps' | cut -d '/' -f 2 | sort -u)
79-
fi
80-
81-
if [ -z "$TARGETS" ] ; then
82-
echo "No targets found. Exiting."
83-
echo "TARGETS=[]" >> $GITHUB_OUTPUT
84-
echo "HAS_TARGETS=false" >> $GITHUB_OUTPUT
85-
else
86-
echo "TARGETS=$TARGETS"
87-
echo "TARGETS=$(echo "$TARGETS" | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> $GITHUB_OUTPUT
92+
TARGETS=$(echo "${{ inputs.target }}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
93+
echo "TARGETS=$TARGETS" >> $GITHUB_OUTPUT
8894
echo "HAS_TARGETS=true" >> $GITHUB_OUTPUT
95+
else
96+
echo "Detecting affected app targets (Turborepo)..."
97+
export TURBO_SCM_BASE=HEAD^
98+
export TURBO_SCM_HEAD=HEAD
99+
TARGETS=$(npx turbo ls --affected --output=json | jq -c '[.packages.items[] | select(.path | startswith("apps/")) | .path | split("/")[1]] | unique | sort')
100+
if [ "$TARGETS" = "[]" ] || [ -z "$TARGETS" ]; then
101+
echo "No affected app targets found."
102+
echo "TARGETS=[]" >> $GITHUB_OUTPUT
103+
echo "HAS_TARGETS=false" >> $GITHUB_OUTPUT
104+
else
105+
echo "TARGETS=$TARGETS"
106+
echo "TARGETS=$TARGETS" >> $GITHUB_OUTPUT
107+
echo "HAS_TARGETS=true" >> $GITHUB_OUTPUT
108+
fi
89109
fi
90110
91111
- name: Generate Unique Build ID

0 commit comments

Comments
 (0)