Skip to content

Commit 96f2035

Browse files
committed
chore: improve scenes deployment
1 parent f46b546 commit 96f2035

2 files changed

Lines changed: 88 additions & 2 deletions

File tree

.github/workflows/deploy-with-version.yml

Lines changed: 88 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ jobs:
3030
runs-on: ubuntu-latest
3131
steps:
3232
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
fetch-tags: false
3336

3437
- uses: actions/setup-node@v4
3538
with:
@@ -60,7 +63,90 @@ jobs:
6063
- name: build
6164
run: npm run build
6265

66+
- name: filter changed scenes
67+
id: filter_workspace
68+
run: |
69+
set -e
70+
71+
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
72+
# Manual run: process all scenes!
73+
echo "workflow_dispatch event detected, processing all scenes"
74+
SCENE_COUNT=$(jq '.folders | length' dcl-workspace.json)
75+
echo "Scene count: $SCENE_COUNT"
76+
if [ "$SCENE_COUNT" -gt 0 ]; then
77+
echo "has_scenes=true" >> $GITHUB_OUTPUT
78+
else
79+
echo "has_scenes=false" >> $GITHUB_OUTPUT
80+
fi
81+
exit 0
82+
fi
83+
84+
# Helper function to get base ref for diff
85+
get_base_ref_for_diff() {
86+
if [ "${{ github.event_name }}" = "pull_request" ]; then
87+
echo "origin/${{ github.base_ref }}"
88+
else
89+
# On push to main, diff with previous commit
90+
# GITHUB_SHA = new commit, GITHUB_REF = refs/heads/main
91+
# git rev-parse <commit>^ = previous commit
92+
echo "$(git rev-parse ${{ github.sha }}^)"
93+
fi
94+
}
95+
96+
# Get diff base
97+
DIFF_BASE=$(get_base_ref_for_diff)
98+
echo "Diff base: $DIFF_BASE"
99+
100+
# Fetch base branch or ensure previous commit exists
101+
if [ "${{ github.event_name }}" = "pull_request" ]; then
102+
git fetch origin ${{ github.base_ref }}:${{ github.base_ref }}
103+
else
104+
git fetch origin main --depth=2
105+
fi
106+
107+
# Get list of changed files
108+
if [ "${{ github.event_name }}" = "pull_request" ]; then
109+
CHANGED_FILES=$(git diff --name-only "$DIFF_BASE"...HEAD)
110+
else
111+
CHANGED_FILES=$(git diff --name-only "$DIFF_BASE" ${{ github.sha }})
112+
fi
113+
echo "$CHANGED_FILES" > changed_files.txt
114+
echo "--- Changed files:"
115+
cat changed_files.txt
116+
echo
117+
118+
echo "--- List all scenes from dcl-workspace.json"
119+
jq -r '.folders[].path' dcl-workspace.json
120+
echo
121+
122+
echo "--- Filter to only scenes with changed files"
123+
SCENES=$(jq -r '.folders[].path' dcl-workspace.json)
124+
NEW_JSON='{"folders":[]}'
125+
for SCENE in $SCENES; do
126+
if grep -q "^$SCENE/" changed_files.txt; then
127+
NEW_JSON=$(echo "$NEW_JSON" | jq --arg p "$SCENE" '.folders += [{"path": $p}]')
128+
echo "Keeping scene: $SCENE"
129+
else
130+
echo "Excluding scene: $SCENE (no changed files)"
131+
fi
132+
done
133+
echo "$NEW_JSON" > dcl-workspace.json
134+
echo
135+
136+
echo "--- Final filtered scenes:"
137+
jq -r '.folders[].path' dcl-workspace.json
138+
139+
# Count scenes and set as output
140+
SCENE_COUNT=$(jq '.folders | length' dcl-workspace.json)
141+
echo "Changed scenes count: $SCENE_COUNT"
142+
if [ "$SCENE_COUNT" -gt 0 ]; then
143+
echo "has_scenes=true" >> $GITHUB_OUTPUT
144+
else
145+
echo "has_scenes=false" >> $GITHUB_OUTPUT
146+
fi
147+
63148
- name: export-static (branch)
149+
if: ${{ steps.filter_workspace.outputs.has_scenes == 'true' }}
64150
run: >
65151
npm run export-static -- \
66152
--realmName ${{steps.get-branch-realm-name.outputs.result}} \
@@ -69,6 +155,7 @@ jobs:
69155
--destination "$(pwd)/ipfs"
70156
71157
- name: upload to s3
158+
if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
72159
run: >
73160
npx @dcl/cdn-uploader@next \
74161
--bucket ${{ secrets.SDK_TEAM_S3_BUCKET }} \
@@ -79,7 +166,7 @@ jobs:
79166
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
80167

81168
- name: Asset Bundle converter queue AllPlataforms
82-
if: github.event_name != 'pull_request'
169+
if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
83170
run: >
84171
npx @dcl/opscli queue-ab-conversion-about \
85172
--token ${{ secrets.AB_TOKEN }} \

advanced-avatar-swap/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ Jump over to the wall keeping the snow from getting on you side to automatically
3838
npm install
3939
```
4040

41-
4241
## Acknowledgements
4342

4443
Model and animations from https://www.mixamo.com/

0 commit comments

Comments
 (0)