feat: added deploy.yml
This commit is contained in:
parent
a957bc6266
commit
af2b22e79c
1 changed files with 41 additions and 0 deletions
41
.github/workflows/deploy.yml
vendored
Normal file
41
.github/workflows/deploy.yml
vendored
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
name: Deploy to Debian Server
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout the code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Set up SSH
|
||||||
|
uses: webfactory/ssh-agent@v0.5.3
|
||||||
|
with:
|
||||||
|
ssh-private-key: ${{ secrets.SSH_KEY }}
|
||||||
|
|
||||||
|
- name: Copy files to server
|
||||||
|
run: |
|
||||||
|
scp -o StrictHostKeyChecking=no docker-compose.yml Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/
|
||||||
|
scp -o StrictHostKeyChecking=no target/your-application.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/home/${{ secrets.SSH_USER }}/munera/
|
||||||
|
|
||||||
|
- name: Deploy on server
|
||||||
|
run: |
|
||||||
|
ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} << 'EOF'
|
||||||
|
cd /home/${{ secrets.SSH_USER }}/munera
|
||||||
|
echo "DB_ADDRESS=${DB_ADDRESS}" > .env
|
||||||
|
echo "DB_USER=${DB_USER}" >> .env
|
||||||
|
echo "DB_PASSWORD=${DB_PASSWORD}" >> .env
|
||||||
|
echo "DB_NAME=${DB_NAME}" >> .env
|
||||||
|
docker-compose down
|
||||||
|
docker-compose up -d --build
|
||||||
|
EOF
|
||||||
|
env:
|
||||||
|
DB_ADDRESS: ${{ secrets.DB_ADDRESS }}
|
||||||
|
DB_USER: ${{ secrets.DB_USER }}
|
||||||
|
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
|
||||||
|
DB_NAME: ${{ secrets.DB_NAME }}
|
Loading…
Reference in a new issue