My minimalistic deployment

In every single one of my projects, I use a very simplified version of automatic deployment to ship my code superfast to the production server.
I use GitHub Action in one of the simplest ways I can imagine.

          
name: Deployment

on:
  push:
    branches:
      - master
      - main
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Pull Newest Change
        uses: appleboy/ssh-action@master
        with:
          host: ${{ secrets.URL }}
          username: ${{ secrets.SSH_USER }}
          key: ${{ secrets.SSH_PRIVATE_KEY }}
          port: ${{ secrets.SSH_PORT }}
          script: |
            cd ~/workspace/my-project
            git pull origin master
            docker-compose exec -T php composer update
            docker-compose exec -T php php bin/console  --no-interaction doctrine:migrations:migrate
            docker-compose exec -T php php bin/console cache:clear --env=prod
        
        
I have a GitHub Action that runs on every push to the master or main branch. It connects to my server via SSH and pulls the newest changes from the repository. After that, it runs a few commands to update the dependencies, run the migrations, and clear the cache.
The credentials are stored in the GitHub repository secrets. So these are also safe and even I don't know them, because I generate them once and store them in the GitHub secret vault.
I know that is not the standard that is used in a lot of companies. But for my projects this more than suitable and makes my life a bit easier. In a proper set up, you would have a service that wrap the entire software in a package, put it on the server, unwrap it and start it. You may, would never have installed git and composer on the server. But for my projects, this is more than enough.
Maybe I will upgrade this process in the future. But not now. Now this is enough and it is fine. I think we should worry less what is the proper way and just keep building.

All rights reserved © Niels Theen