Skip to content

Commit 47e8097

Browse files
authored
fix: add some checks to deploy scripts (closes #246)
fix: add some checks to deploy scripts the rsync command in the github actions runs --delete which clear the current folder. if this runs in the wrong directory it should cause problems. the deploy script should now check that variables are set correctly before attempting to do the rsync
1 parent 2456ef9 commit 47e8097

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/deploy.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,24 @@ jobs:
212212
port: ${{ secrets.EXP_DEPLOY_PORT }}
213213
script: rm ${{ secrets.EXP_DEPLOY_PATH }}/e/${{ steps.dotenv_github.outputs.VITE_CODE_NAME }}; ln -sf ${{ secrets.EXP_DEPLOY_PATH }}/${{ steps.dotenv_github.outputs.VITE_DEPLOY_BASE_PATH }} ${{ secrets.EXP_DEPLOY_PATH }}/e/${{ steps.dotenv_github.outputs.VITE_CODE_NAME }}
214214

215+
# Validate deploy variables before rsync --delete (safety check)
216+
- name: Validate deploy path variables
217+
run: |
218+
if [ -z "${{ secrets.EXP_DEPLOY_PATH }}" ]; then
219+
echo "::error::EXP_DEPLOY_PATH secret is not set. Aborting to prevent rsync --delete in wrong directory."
220+
exit 1
221+
fi
222+
if [ -z "${{ steps.dotenv_github.outputs.VITE_DEPLOY_BASE_PATH }}" ]; then
223+
echo "::error::VITE_DEPLOY_BASE_PATH is not set. Aborting to prevent rsync --delete in wrong directory."
224+
exit 1
225+
fi
226+
FULL_PATH="${{ secrets.EXP_DEPLOY_PATH }}/${{ steps.dotenv_github.outputs.VITE_DEPLOY_BASE_PATH }}"
227+
if [ -z "$FULL_PATH" ] || [ "$FULL_PATH" = "/" ]; then
228+
echo "::error::Computed deploy path is empty or root. Aborting to prevent rsync --delete in wrong directory."
229+
exit 1
230+
fi
231+
echo "Deploy path validated: $FULL_PATH"
232+
215233
# Deploy files to web server
216234
- name: rsync to server
217235
uses: burnett01/rsync-deployments@5.2

.github/workflows/docs-deploy.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,19 @@ jobs:
159159
- name: Rebuild docs
160160
run: npm run docs:build
161161

162+
# Validate deploy variables before rsync --delete (safety check)
163+
- name: Validate deploy path variables
164+
run: |
165+
if [ -z "${{ secrets.DOCS_DEPLOY_PATH }}" ]; then
166+
echo "::error::DOCS_DEPLOY_PATH secret is not set. Aborting to prevent rsync --delete in wrong directory."
167+
exit 1
168+
fi
169+
if [ "${{ secrets.DOCS_DEPLOY_PATH }}" = "/" ]; then
170+
echo "::error::DOCS_DEPLOY_PATH is root. Aborting to prevent rsync --delete in wrong directory."
171+
exit 1
172+
fi
173+
echo "Deploy path validated: ${{ secrets.DOCS_DEPLOY_PATH }}"
174+
162175
# Deploy files to web server
163176
- name: rsync to server
164177
uses: burnett01/rsync-deployments@5.2

0 commit comments

Comments
 (0)