Skip to content

Deploy to Server

Deploy to Server #7

Workflow file for this run

name: Deploy to Server
on:
workflow_run:
workflows: ["Build and Push Docker Image"]
types:
- completed
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy to Server
uses: appleboy/[email protected]
with:
host: ${{ secrets.SERVER_HOST }}
username: ${{ secrets.SERVER_USER }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
port: ${{ secrets.SERVER_PORT }}
script: |
docker pull ${{ secrets.DOCKER_USERNAME }}/mailfort:latest
docker stop mailfort_container || true
docker rm mailfort_container || true
echo ${{ secrets.MAIL_HOST }} > .env
echo ${{ secrets.MAIL_PORT }} >> .env
echo ${{ secrets.MAIL_USERNAME }} >> .env
echo ${{ secrets.MAIL_PASSWORD }} >> .env
scp -o StrictHostKeyChecking=no ./config/prod.yaml ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:./config/
docker run -d -p 8350:8080 --name mailfort_container -e CONFIG_PATH=./config/prod.yaml ${{ secrets.DOCKER_USERNAME }}/mailfort:latest