Deploy to Server #9
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 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: | | |
# Download the next version of Docker from Docker Hub | |
docker pull ${{ secrets.DOCKER_USERNAME }}/mailfort:latest | |
# Install and use the mailfort_container container, if it works | |
docker stop mailfort_container || true | |
docker rm mailfort_container || true | |
# Copy the prod configuration prod.yaml on the server | |
scp -o StrictHostKeyChecking=no ./config/prod.yaml ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_HOST }}:./config/ | |
# We invite the docker manager with suggestions for a change of environment and high-tech constrictions | |
docker run -d -p 8350:8080 --name mailfort_container \ | |
-e MAIL_HOST="${{ secrets.MAIL_HOST }}" \ | |
-e MAIL_PORT="${{ secrets.MAIL_PORT }}" \ | |
-e MAIL_USERNAME="${{ secrets.MAIL_USERNAME }}" \ | |
-e MAIL_PASSWORD="${{ secrets.MAIL_PASSWORD }}" \ | |
-e CONFIG_PATH=./config/prod.yaml \ | |
${{ secrets.DOCKER_USERNAME }}/mailfort:latest |