Skip to content
Merged
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
50 changes: 36 additions & 14 deletions .github/workflows/deploy-base.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,28 +64,50 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Fetch base commit for Turbo diff
if: inputs.target == ''
run: git fetch origin ${{ github.event.before }} --depth=1

- 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:
fetch-depth: 2
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 | awk -F/ '/^(apps|jobs)\//{print $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=${{ github.event.before }}
export TURBO_SCM_HEAD=${{ github.sha }}
TARGETS=$(npx turbo ls --affected --output=json | jq -c '[.packages.items[] | select(.path | (startswith("apps/") or startswith("jobs/"))) | .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
103 changes: 103 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "@wxyc/backend-services",
"version": "1.0.0",
"description": "All necessary app services for the WXYC flowsheet backend",
"packageManager": "npm@10.9.4",
"scripts": {
"typecheck": "npm run build --workspace=@wxyc/database --workspace=@wxyc/authentication && npm run typecheck --workspace=@wxyc/database --workspace=shared/** --workspace=apps/**",
"lint": "eslint --cache --cache-strategy content --cache-location .cache/eslint/ .",
Expand Down Expand Up @@ -71,6 +72,7 @@
"supertest": "^7.0.0",
"ts-jest": "^29.4.6",
"ts-node": "^10.9.2",
"turbo": "^2.3.0",
"tsup": "^8.4.0",
"tsx": "^4.21.0",
"typescript": "^5.6.2",
Expand Down
6 changes: 6 additions & 0 deletions turbo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"globalDependencies": ["tsconfig.base.json"],
"tasks": {
"build": { "outputs": ["dist/**"] }
}
}
Loading