Hi, I come from using Plesk, which allows you to enter details for github's webhook and deploy key. So each time I push to github it will update the server's copy of git, and then automatically deploy the changes to my website. Will it be difficult to do this on opalstack? I am not familiar with server scripts.

  • nick replied to this.

    wynlim To replicate the functionality here, you'll need to set it up manually. First, learn about GitHub webhooks from their documentation (https://docs.github.com/en/webhooks). Then create a web application for your site at our end that will receive GitHub's webhook data and perform the necessary actions. The script you would implement for that site could be written in Python, Node.js, or PHP, etc. You probably can find some workable templates online (just be sure to examine them before using them). If you nominate PHP, we'll likely have to enable shell_exec function for the app you want to use it with.

    I got this working on my OpalStack project using GitHub Actions :
    https://github.com/appleboy/ssh-action

    name: Deploy via Git Pull and Restart Server
    on:
      push:
        branches:
          - main
    jobs:
      deploy:
        runs-on: ubuntu-latest
        steps:
          - name: Checkout code
            uses: actions/checkout@v2
          - name: Restart server via SSH
            uses: appleboy/ssh-action@master
            with:
              host: ${{ secrets.SSH_HOST }}
              username: ${{ secrets.SSH_USERNAME }}
              password: ${{ secrets.SSH_PASSWORD }}
              script: |
                cd /home/username/laravel/projectName
                git pull            
            env:
              SSH_KNOWN_HOSTS_CONTENT: ${{ secrets.SSH_KNOWN_HOSTS_CONTENT }}

      I use a similar Github action. Just works 👌

      anjanesh is your project a docker container? it says it only works on docker containers? thanks for the help btw. 🙂

      No, not at all - its on Opalstack - the action file just logs into my opalstack a/c and switches to the project directory and does a git pull. Nothing more.

      Mastodon