Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 33 additions & 13 deletions .github/workflows/deploy-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,25 +67,45 @@ jobs:
with:
fetch-depth: 2

- name: Set up Node.js
if: inputs.target == ''
uses: actions/setup-node@v4
with:
node-version: '20'

- name: Cache node_modules
if: inputs.target == ''
uses: actions/cache@v4
with:
path: node_modules
key: deploy-node-modules-${{ runner.os }}-node20-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
if: inputs.target == ''
run: npm ci

- name: Detect Build Target
id: detect_targets
run: |
if [ -n "${{ inputs.target }}" ]; then
echo "Using provided target: ${{ inputs.target }}"
TARGETS="${{ inputs.target }}"
else
echo "Detecting targets from git diff..."
TARGETS=$(git diff --name-only HEAD~1..HEAD | grep '^apps' | cut -d '/' -f 2 | sort -u)
fi

if [ -z "$TARGETS" ] ; then
echo "No targets found. Exiting."
echo "TARGETS=[]" >> $GITHUB_OUTPUT
echo "HAS_TARGETS=false" >> $GITHUB_OUTPUT
else
echo "TARGETS=$TARGETS"
echo "TARGETS=$(echo "$TARGETS" | jq -R -s -c 'split("\n") | map(select(length > 0))')" >> $GITHUB_OUTPUT
TARGETS=$(echo "${{ inputs.target }}" | jq -R -s -c 'split("\n") | map(select(length > 0))')
echo "TARGETS=$TARGETS" >> $GITHUB_OUTPUT
echo "HAS_TARGETS=true" >> $GITHUB_OUTPUT
else
echo "Detecting affected app targets (Turborepo)..."
export TURBO_SCM_BASE=HEAD^
export TURBO_SCM_HEAD=HEAD
TARGETS=$(npx turbo ls --affected --output=json | jq -c '[.packages.items[] | select(.path | startswith("apps/")) | .path | split("/")[1]] | unique | sort')
if [ "$TARGETS" = "[]" ] || [ -z "$TARGETS" ]; then
echo "No affected app targets found."
echo "TARGETS=[]" >> $GITHUB_OUTPUT
echo "HAS_TARGETS=false" >> $GITHUB_OUTPUT
else
echo "TARGETS=$TARGETS"
echo "TARGETS=$TARGETS" >> $GITHUB_OUTPUT
echo "HAS_TARGETS=true" >> $GITHUB_OUTPUT
fi
fi

- name: Generate Unique Build ID
Expand Down
Loading
Loading