Deploy Preview #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy Preview | |
on: | |
workflow_run: | |
workflows: ["Run Tests"] | |
types: | |
- completed | |
branches: | |
- 'main' | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to Preview Server | |
uses: appleboy/[email protected] | |
env: | |
MICONFIG: ${{ secrets.MICONFIG_PREVIEW }} | |
PK: ${{ secrets.BENTO_PK_PREVIEW }} | |
with: | |
host: ${{ secrets.PREVIEW_SERVER_IP }} | |
username: ${{ secrets.PREVIEW_USER }} | |
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 | |
git clone [email protected]:${{ github.repository }}.git repo | |
cd repo | |
echo "Copy deploy preview script" | |
cp .github/scripts/deploy-preview.sh . | |
echo "Running deploy-preview.sh" | |
chmod +x deploy-preview.sh | |
./deploy-preview.sh | |
clean_up |