Skip to content

Commit

Permalink
add better error handler to preview deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
juancwu committed Nov 8, 2024
1 parent 0897d5b commit cfe0d2a
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions .github/workflows/deploy-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,21 @@ jobs:
key: ${{ secrets.PREVIEW_SERVER_SSH_KEY }}
envs: MICONFIG,PK
script: |
clean_up() {
echo "Performing cleanup..."
cd ~
echo "Remove repository"
rm -rf repo
echo "Docker cleanup"
docker system prune -f
echo "Done: Cleanup"
}
handle_error() {
clean_up
echo "Failed to deploy preview"
exit 1
}
trap 'handler_error' ERR
echo "Cloning repository"
cd ~
rm -rf repo
Expand All @@ -27,11 +42,4 @@ jobs:
cp .github/scripts/deploy-preview.sh .
echo "Running deploy-preview.sh"
chmod +x deploy-preview.sh
./deploy-preview.sh || echo "Failed to deploy preview"
echo "Performing cleanup..."
cd ~
echo "Remove repository"
rm -rf repo
echo "Docker cleanup"
docker system prune -f
echo "Done: Cleanup"
./deploy-preview.sh

0 comments on commit cfe0d2a

Please sign in to comment.