Skip to content

Commit a7a67d7

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

1 file changed

Lines changed: 146 additions & 123 deletions

File tree

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

Lines changed: 146 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ on:
2424
required: true
2525
AB_TOKEN:
2626
required: true
27+
push:
28+
branches:
29+
- 'chore/improve-scenes-deploy'
2730

2831
jobs:
2932
build-and-deploy:
@@ -63,87 +66,87 @@ jobs:
6366
- name: build
6467
run: npm run build
6568

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

148151
- name: export-static (branch)
149152
if: ${{ steps.filter_workspace.outputs.has_scenes == 'true' }}
@@ -154,46 +157,66 @@ jobs:
154157
--baseUrl '${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs' \
155158
--destination "$(pwd)/ipfs"
156159
157-
- name: upload to s3
158-
if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
159-
run: >
160-
npx @dcl/cdn-uploader@next \
161-
--bucket ${{ secrets.SDK_TEAM_S3_BUCKET }} \
162-
--local-folder "$(pwd)/ipfs" \
163-
--bucket-folder 'ipfs'
164-
env:
165-
AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
166-
AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
167-
168-
- name: Asset Bundle converter queue AllPlataforms
169-
if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
170-
run: >
171-
npx @dcl/opscli queue-ab-conversion-about \
172-
--token ${{ secrets.AB_TOKEN }} \
173-
--prioritize \
174-
--about-url ${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}}/about
175-
176-
- name: Find Comment
177-
uses: peter-evans/find-comment@v1
178-
if: github.event_name == 'pull_request'
179-
id: fc
180-
with:
181-
issue-number: ${{ github.event.pull_request.number }}
182-
comment-author: 'github-actions[bot]'
183-
body-includes: Test this pull request
160+
- name: Print local about file
161+
if: ${{ steps.filter_workspace.outputs.has_scenes == 'true' }}
162+
run: |
163+
set -e
164+
FILE="ipfs/${{ steps.get-branch-realm-name.outputs.result }}/about"
165+
echo "Contents of $FILE:"
166+
if [ -f "$FILE" ]; then
167+
cat "$FILE"
168+
else
169+
echo "File not found: $FILE"
170+
fi
184171
185-
- name: Create or update comment
186-
uses: peter-evans/create-or-update-comment@v1
187-
if: github.event_name == 'pull_request'
188-
with:
189-
comment-id: ${{ steps.fc.outputs.comment-id }}
190-
issue-number: ${{ github.event.pull_request.number }}
191-
body: |
192-
## Test this pull request
193-
- [Test in-world](https://play.decentraland.zone/?realm=${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}})
194-
- Or use this chat command to switch the realm
195-
```bash
196-
/goto ${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}}
197-
```
198-
This PR has been published using the `@dcl/sdk` version `${{ inputs.dcl-sdk-package }}`
199-
edit-mode: replace
172+
- name: Print remote about file from CDN
173+
if: ${{ steps.filter_workspace.outputs.has_scenes == 'true' }}
174+
run: |
175+
set -e
176+
URL="https://sdk-team-cdn.decentraland.org/ipfs/goerli-plaza-main-latest/about"
177+
echo "Contents of $URL:"
178+
curl -fLs "$URL" || echo "Remote about file not found or not accessible"
179+
180+
# - name: upload to s3
181+
# if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
182+
# run: >
183+
# npx @dcl/cdn-uploader@next \
184+
# --bucket ${{ secrets.SDK_TEAM_S3_BUCKET }} \
185+
# --local-folder "$(pwd)/ipfs" \
186+
# --bucket-folder 'ipfs'
187+
# env:
188+
# AWS_ACCESS_KEY_ID: ${{ secrets.SDK_TEAM_AWS_ID }}
189+
# AWS_SECRET_ACCESS_KEY: ${{ secrets.SDK_TEAM_AWS_SECRET }}
190+
191+
# - name: Asset Bundle converter queue AllPlataforms
192+
# if: ${{ github.event_name != 'pull_request' && steps.filter_workspace.outputs.has_scenes == 'true' }}
193+
# run: >
194+
# npx @dcl/opscli queue-ab-conversion-about \
195+
# --token ${{ secrets.AB_TOKEN }} \
196+
# --prioritize \
197+
# --about-url ${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}}/about
198+
199+
# - name: Find Comment
200+
# uses: peter-evans/find-comment@v1
201+
# if: github.event_name == 'pull_request'
202+
# id: fc
203+
# with:
204+
# issue-number: ${{ github.event.pull_request.number }}
205+
# comment-author: 'github-actions[bot]'
206+
# body-includes: Test this pull request
207+
208+
# - name: Create or update comment
209+
# uses: peter-evans/create-or-update-comment@v1
210+
# if: github.event_name == 'pull_request'
211+
# with:
212+
# comment-id: ${{ steps.fc.outputs.comment-id }}
213+
# issue-number: ${{ github.event.pull_request.number }}
214+
# body: |
215+
# ## Test this pull request
216+
# - [Test in-world](https://play.decentraland.zone/?realm=${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}})
217+
# - Or use this chat command to switch the realm
218+
# ```bash
219+
# /goto ${{ secrets.SDK_TEAM_S3_BASE_URL }}/ipfs/${{steps.get-branch-realm-name.outputs.result}}
220+
# ```
221+
# This PR has been published using the `@dcl/sdk` version `${{ inputs.dcl-sdk-package }}`
222+
# edit-mode: replace

0 commit comments

Comments
 (0)