@@ -16,54 +16,77 @@ jobs:
1616 with :
1717 ref : main
1818
19- - name : Download and extract build
19+ - name : Download artifact
2020 run : |
2121 set -euo pipefail
2222 ARTIFACT_URL="${{ github.event.client_payload.artifact_url }}"
2323 TOKEN="${{ secrets.BETA_PAT_TOKEN }}"
2424
2525 echo "Downloading artifact from: ${ARTIFACT_URL}"
26- curl -L -H "Authorization: token ${TOKEN}" -o htmlplayer-build.zip "${ARTIFACT_URL}"
26+ curl -L -H "Authorization: token ${TOKEN}" -o outer-artifact.zip "${ARTIFACT_URL}"
27+
28+ - name : Extract artifact(s)
29+ run : |
30+ set -euo pipefail
2731
28- echo "Unzipping outer artifact..."
2932 mkdir -p temp-build
30- unzip -q htmlplayer-build.zip -d temp-build
3133
32- echo "Unzipping inner build zip..."
33- unzip -q temp-build/htmlplayer-build.zip -d temp-build
34+ echo "Unzipping outer artifact to temp-build..."
35+ unzip -q outer-artifact.zip -d temp-build
36+
37+ # Find any zip inside temp-build (inner/packaged zip). Support any name.
38+ INNER_ZIP="$(find temp-build -maxdepth 2 -type f -name '*.zip' -print -quit || true)"
39+
40+ if [ -n "${INNER_ZIP:-}" ]; then
41+ echo "Found inner zip: ${INNER_ZIP}"
42+ unzip -q "${INNER_ZIP}" -d temp-build
43+ rm -f "${INNER_ZIP}"
44+ else
45+ echo "No inner zip found under temp-build; maybe outer zip directly contained files."
46+ fi
3447
35- # keep workspace clean
36- rm -f temp-build/htmlplayer-build.zip htmlplayer-build .zip
48+ # Clean up the downloaded outer zip
49+ rm -f outer-artifact .zip
3750
38- - name : Replace subfolder with Build/dist contents
51+ - name : Place Build/dist contents into subfolder
3952 run : |
4053 set -euo pipefail
4154 SUBFOLDER="${{ github.event.client_payload.subfolder }}"
42-
4355 echo "Target subfolder: ${SUBFOLDER}"
4456
4557 # Ensure subfolder exists
4658 mkdir -p "${SUBFOLDER}"
4759
48- # Clear subfolder (including hidden files, but keep the dir itself)
49- # The printf + xargs pattern avoids errors when the glob is empty.
50- if [ -d "${SUBFOLDER}" ]; then
51- echo "Clearing existing contents of ${SUBFOLDER}"
52- find "${SUBFOLDER}" -mindepth 1 -maxdepth 1 -print0 | xargs -0 rm -rf --
60+ # Clear subfolder including hidden files (but keep the dir)
61+ echo "Clearing existing contents of ${SUBFOLDER}"
62+ find "${SUBFOLDER}" -mindepth 1 -maxdepth 1 -print0 | xargs -0 --no-run-if-empty rm -rf --
63+
64+ # Determine source dist path
65+ # Look for Build/dist under temp-build
66+ DIST_DIR="$(find temp-build -type d -path '*/Build/dist' -print -quit || true)"
67+
68+ # If not found, also look for any directory named 'dist'
69+ if [ -z "${DIST_DIR:-}" ]; then
70+ DIST_DIR="$(find temp-build -type d -name 'dist' -print -quit || true)"
5371 fi
5472
55- # Sanity check: ensure source path exists
56- if [ ! -d "temp-build/Build/dist" ]; then
57- echo "ERROR: temp-build/Build/dist does not exist"
58- echo "Actual temp-build structure:"
59- find temp-build -maxdepth 5 -print
73+ if [ -z "${DIST_DIR:-}" ]; then
74+ echo "ERROR: could not find a 'Build/dist' or 'dist' directory under temp-build:"
75+ find temp-build -maxdepth 4 -print
6076 exit 1
6177 fi
6278
63- echo "Copying new build contents from temp-build/Build/dist into ${SUBFOLDER}"
64- # Move contents of dist/* directly into SUBFOLDER
79+ echo "Using dist source: ${DIST_DIR}"
80+
81+ # Move contents of dist into subfolder (preserve dotfiles)
6582 shopt -s dotglob nullglob
66- mv temp-build/Build/dist/* "${SUBFOLDER}/"
83+ files=( "${DIST_DIR}"/* )
84+ if [ ${#files[@]} -gt 0 ]; then
85+ echo "Moving ${#files[@]} items from ${DIST_DIR} -> ${SUBFOLDER}"
86+ mv "${files[@]}" "${SUBFOLDER}/"
87+ else
88+ echo "Warning: ${DIST_DIR} is empty; nothing to move."
89+ fi
6790
6891 - name : Commit and push
6992 run : |
@@ -74,13 +97,14 @@ jobs:
7497 git config --global user.name 'github-actions[bot]'
7598 git config --global user.email 'github-actions[bot]@users.noreply.github.com'
7699
77- git add "${SUBFOLDER}"
100+ # Stage only the subfolder (including deletions)
101+ git add -A "${SUBFOLDER}"
78102
79103 if git diff --staged --quiet; then
80104 echo "No changes to commit"
81105 else
82106 echo "Changes detected; committing..."
83- git status
107+ git status --porcelain
84108 git commit -m "Deploy ${SOURCE_REPO} build to ${SUBFOLDER}"
85109 git push origin main
86110 fi
0 commit comments