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?
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:
for 1-4 I think we can use the API, but for the others not sure
drocha my recommendation is that you use a custom install script, eg:
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:
create_app
and with an installer_url
which will clone and build and etcAlso, I'm JS, any chance you have any JS-based installer ?
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:
create_app
call.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:
So if you can do those things in JS, then you've got the basics covered.
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 }}
db122 I wonder if anyone's tried their luck with https://github.com/marketplace/actions/ftp-deploy - I am yet to try it - will do so later tonight - but there is an entry runs-on: ubuntu-latest
- is this mandatory for FTP ?
sean In this case, it's a moot point because Opalstack does not support plain FTP.
I use both https://github.com/appleboy/ssh-action and https://github.com/easingthemes/ssh-deploy to deploy to Opalstack without issues. The former when I need to run a script on my opalstack server (to restart services, etc), the latter when it's sufficient to rsync files across.
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 }}