Is there a guide or demo to programatically access Opalstack ? I'd like to make some Github Actions (if there are any) to automatically trigger deploys.

Or is there a better/another way to do so?

Programmatic access to the service is available via our REST API: https://my.opalstack.com/api/v1/doc/

If you can let me know the exact steps you want to accomplish then I might be able to provide some specific examples.

I'm planning to:

  1. create a static hosting app
  2. create a subdomain
  3. link that subdomain to the newly created app
  4. create a node app
  5. clone a repo in that node app (Next, Gatsby, etc -- Jasmstack)
  6. build the node app
  7. move files to the static hosting app (if output can't be configured)

for 1-4 I think we can use the API, but for the others not sure

  • sean replied to this.

    drocha my recommendation is that you use a custom install script, eg:

    1. Create a script that performs the tasks you need to do, with the exception of step 1.
    2. Upload the script to a public site or repo.
    3. Use the create_app method of the API to create your static app (ie step 1), and include the URL of your script as the installer_url parameter.

    This way when the static app is created it will fetch your custom install script and run it on the server as part of the installation process.

    Feel free to have a look through our installer repo to see how some of our own installer scripts work - most of ours are done in Python but there are a couple in there that are done with bash.

    Thanks ! that's very useful, although … my plan is to replace the previews functionality Netlify has and also do automatic updates when a PR gets merged to the main branch, any guidance there ?

    So a few more actions:

    1. Do all that previously explained when creating a PR -- using create_app and with an installer_url which will clone and build and etc
    2. Update that same app with every commit pushed to the PR
    3. Update the main app when merging PRs (or actually any new commits on the main branch)
    • sean replied to this.

      Also, I'm JS, any chance you have any JS-based installer ?

      • sean replied to this.

        drocha my plan is to replace the previews functionality Netlify has and also do automatic updates when a PR gets merged to the main branch, any guidance there ?

        I've never used GH Actions myself so I can't tell you what to do on that end, but on our end you can do the following:

        • You can use our API to do the things that you would normally do in the dashboard (including the ability to fetch an run an arbitrary script as part of a create_app call.
        • You can use SSH to log in and run scripts
        • You can use SFTP or scp to transfer files to and from the server.
        • You can make a website with endpoints that you can hit to run whatever actions on the server, in whatever scripting language you like.

        drocha Also, I'm JS, any chance you have any JS-based installer ?

        No, we don't have any existing installers written in JS. There's nothing really language-specific in the installers though, they mostly do things like:

        • Make HTTP requests to download files and make API calls.
        • Modify files
        • Run other programs and shell commands

        So if you can do those things in JS, then you've got the basics covered.

        8 months later

        I was wonder if GitHub Actions can be used to update the code on an app on OpalStack server ?

        I git push origin main to GitHub and an action can be created to auto-update the Django app on my OpalStack server and then auto-restart the app's server ?

          anjanesh I use an ssh-deploy plugin (https://github.com/easingthemes/ssh-deploy) to deploy new react app code. Works well for me. If it were a server, there are SSH exec plugins you can use to run commands to restart the server.

          - name: Deploy to Server
              uses: easingthemes/ssh-deploy@main
                  env:
                    SSH_PRIVATE_KEY: ${{ secrets.SERVER_SSH_KEY }}
                    ARGS: "-rltgoDzvO --delete"
                    SOURCE: "build/"
                    REMOTE_HOST: ${{ secrets.REMOTE_HOST }}
                    REMOTE_USER: ${{ secrets.REMOTE_USER }}
                    TARGET: ${{ secrets.REMOTE_TARGET }}
            3 months later

            anjanesh I think "runs-on" refers to the VM that the action uses on the Github side.

            In this case, it's a moot point because Opalstack does not support plain FTP.

              anjanesh Opalstack supports SFTP and scp, not FTPS.

              18 days later

              With the help of ChatGPT I got this resolved.
              In .github/workflows/main.yml :

              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/apps/appName/appName
                          git pull            
                          ./stop
                          ./start
                      env:
                        SSH_KNOWN_HOSTS_CONTENT: ${{ secrets.SSH_KNOWN_HOSTS_CONTENT }}
              Mastodon