Skip to content

Commit 3252d65

Browse files
authored
Refactor beta build workflow for clarity and efficiency
1 parent 7b8b907 commit 3252d65

1 file changed

Lines changed: 55 additions & 11 deletions

File tree

.github/workflows/receive-beta-build.yml

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,78 @@ jobs:
1818

1919
- name: Download and extract build
2020
run: |
21+
set -euo pipefail
2122
ARTIFACT_URL="${{ github.event.client_payload.artifact_url }}"
2223
TOKEN="${{ secrets.BETA_PAT_TOKEN }}"
24+
25+
echo "Downloading artifact from: ${ARTIFACT_URL}"
2326
curl -L -H "Authorization: token ${TOKEN}" -o htmlplayer-build.zip "${ARTIFACT_URL}"
24-
unzip htmlplayer-build.zip -d temp-build
25-
unzip temp-build/htmlplayer-build.zip -d temp-build
26-
rm temp-build/htmlplayer-build.zip # Remove the inner zip so only build files are moved
27-
28-
- name: Clear and copy to subfolder
27+
28+
echo "Unzipping outer artifact..."
29+
mkdir -p temp-build
30+
unzip -q htmlplayer-build.zip -d temp-build
31+
32+
echo "Unzipping inner build zip..."
33+
unzip -q temp-build/htmlplayer-build.zip -d temp-build
34+
35+
# Optional: keep workspace clean
36+
rm -f temp-build/htmlplayer-build.zip htmlplayer-build.zip
37+
38+
echo "Resulting structure under temp-build:"
39+
find temp-build -maxdepth 3 -type d -print
40+
41+
- name: Replace subfolder with Build/dist contents
2942
run: |
43+
set -euo pipefail
3044
SUBFOLDER="${{ github.event.client_payload.subfolder }}"
31-
echo "Copying to ${SUBFOLDER}"
32-
ls "${SUBFOLDER}"
33-
rm -rf "${SUBFOLDER}"/*
45+
46+
echo "Target subfolder: ${SUBFOLDER}"
47+
48+
# Ensure subfolder exists
3449
mkdir -p "${SUBFOLDER}"
35-
mv temp-build/* "${SUBFOLDER}/"
36-
echo "Contents after move:"
37-
ls -la "${SUBFOLDER}/" # Debug: list contents
50+
51+
echo "Before replace, contents of ${SUBFOLDER}:"
52+
ls -la "${SUBFOLDER}" || true
53+
54+
# Clear subfolder (including hidden files, but keep the dir itself)
55+
# The printf + xargs pattern avoids errors when the glob is empty.
56+
if [ -d "${SUBFOLDER}" ]; then
57+
echo "Clearing existing contents of ${SUBFOLDER}"
58+
find "${SUBFOLDER}" -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf --
59+
fi
60+
61+
# Sanity check: ensure source path exists
62+
if [ ! -d "temp-build/Build/dist" ]; then
63+
echo "ERROR: temp-build/Build/dist does not exist"
64+
echo "Actual temp-build structure:"
65+
find temp-build -maxdepth 5 -print
66+
exit 1
67+
fi
68+
69+
echo "Copying new build contents from temp-build/Build/dist into ${SUBFOLDER}"
70+
# Move contents of dist/* directly into SUBFOLDER
71+
shopt -s dotglob nullglob
72+
mv temp-build/Build/dist/* "${SUBFOLDER}/"
73+
74+
echo "After replace, contents of ${SUBFOLDER}:"
75+
ls -la "${SUBFOLDER}"
3876
3977
- name: Commit and push
4078
run: |
79+
set -euo pipefail
4180
SUBFOLDER="${{ github.event.client_payload.subfolder }}"
4281
SOURCE_REPO="${{ github.event.client_payload.source_repo }}"
82+
4383
git config --global user.name 'github-actions[bot]'
4484
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
85+
4586
git add "${SUBFOLDER}"
87+
4688
if git diff --staged --quiet; then
4789
echo "No changes to commit"
4890
else
91+
echo "Changes detected; committing..."
92+
git status
4993
git commit -m "Deploy ${SOURCE_REPO} build to ${SUBFOLDER}"
5094
git push origin main
5195
fi

0 commit comments

Comments
 (0)