Skip to content

Commit 98fdecb

Browse files
authored
Allow deploy without ebooks (#3454)
1 parent d3ccedc commit 98fdecb

1 file changed

Lines changed: 17 additions & 12 deletions

File tree

src/tools/scripts/deploy.sh

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,14 @@ WORKFLOW_ID=predeploy.yml
116116
# Get the latest workflow run ID and download its artifact's ZIP file
117117
RUN_ID=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/workflows/${WORKFLOW_ID}/runs" | jq -r '.workflow_runs[0].id')
118118
ARTIFACT_ID=$(curl -s -H "Authorization: token ${GITHUB_TOKEN}" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/runs/${RUN_ID}/artifacts" | jq -r '.artifacts[0].id')
119-
curl -L -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/artifacts/${ARTIFACT_ID}/zip" -o "${ARTIFACT_ID}.zip"
120119

121-
# Extract the contents of the ZIP file and clean up
122-
unzip -q "${ARTIFACT_ID}.zip" -d ./static/pdfs/
123-
rm "${ARTIFACT_ID}.zip"
120+
if [[ "${ARTIFACT_ID}" != "null" ]]; then
121+
curl -L -H "Authorization: token ${GITHUB_TOKEN}" -H "Accept: application/vnd.github.v3+json" "https://api.github.com/repos/${REPO_OWNER}/${REPO_NAME}/actions/artifacts/${ARTIFACT_ID}/zip" -o "${ARTIFACT_ID}.zip"
122+
123+
# Extract the contents of the ZIP file and clean up
124+
unzip -q "${ARTIFACT_ID}.zip" -d ./static/pdfs/
125+
rm "${ARTIFACT_ID}.zip"
126+
fi
124127

125128
echo "Run and test website"
126129
./tools/scripts/run_and_test_website.sh
@@ -171,14 +174,16 @@ zip -q -r deployed . --exclude @.gcloudignore static/images/*/*/* static/pdfs/*
171174
echo "Deploying to GCP"
172175
echo "Y" | gcloud app deploy --project webalmanac --stop-previous-version
173176

174-
echo "Deploying ebooks to GCP Storage"
175-
# shellcheck disable=SC2010
176-
pdfs=$(cd static/pdfs;ls web_almanac_* | grep -v print | grep -v cover)
177-
for pdf in ${pdfs}
178-
do
179-
echo "Uploading $pdf"
180-
gsutil cp "static/pdfs/${pdf}" "gs://httparchive/almanac/ebooks/${pdf}"
181-
done
177+
if [[ "${ARTIFACT_ID}" != "null" ]]; then
178+
echo "Deploying ebooks to GCP Storage"
179+
# shellcheck disable=SC2010
180+
pdfs=$(cd static/pdfs;ls web_almanac_* | grep -v print | grep -v cover)
181+
for pdf in ${pdfs}
182+
do
183+
echo "Uploading $pdf"
184+
gsutil cp "static/pdfs/${pdf}" "gs://httparchive/almanac/ebooks/${pdf}"
185+
done
186+
fi
182187

183188
echo "Push production branch"
184189
git push

0 commit comments

Comments
 (0)