Skip to content

Commit 7c52e28

Browse files
Merge pull request #19 from LegReq/fix-branch-deploy
Fix error in deploying branches to subfolder on gh-pages
2 parents 0a1482f + 38d7af4 commit 7c52e28

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

action.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ runs:
111111
repository_name="${{ github.event.repository.name }}"
112112
lower_repository_name=$(echo "$repository_name" | tr "[:upper:]" "[:lower:]")
113113
114-
if [[ "$lower_repository_name" == "host_name" ]]
114+
if [[ "$lower_repository_name" == "$host_name" ]]
115115
then
116116
pages_url="https://$host_name"
117117
else
@@ -121,14 +121,14 @@ runs:
121121
pages_archive=${{ inputs.pages-archive }}
122122
123123
# Get and unzip GitHub Pages archive.
124-
curl -s $pages_url/"$pages_archive".zip -o "$pages_archive".zip
125-
if [[ $? -eq 0 ]]
126-
then
127-
unzip -qq "$pages_archive".zip -d "$pages_archive"
128-
rm "$pages_archive".zip
124+
# Fail on 404 and similar so we fall back properly
125+
curl -fSL "$pages_url/${{ inputs.pages-archive }}.zip" -o "${{ inputs.pages-archive }}.zip"
126+
if unzip -qq "${{ inputs.pages-archive }}.zip" -d "${{ inputs.pages-archive }}"; then
127+
rm "${{ inputs.pages-archive }}.zip"
129128
else
130-
# First time including branches. Treat current content as default branch; will be fixed on next push to default branch.
131-
cp -r "${{ inputs.pages-path }}" "$pages_archive"/
129+
echo "No existing pages archive; seeding new one"
130+
mkdir -p "${{ inputs.pages-archive }}"
131+
cp -r "${{ inputs.pages-path }}" "${{ inputs.pages-archive }}/"
132132
fi
133133
134134
cd "$pages_archive"

0 commit comments

Comments
 (0)