Skip to content

Deploy example endpoint #27

Deploy example endpoint

Deploy example endpoint #27

name: Deploy example endpoint
on:
workflow_dispatch: {}
workflow_run:
workflows: ["Nightly Build"]
types:
- completed
jobs:
get-ref:
name: Get nightly ref
runs-on: ubuntu-latest
outputs:
ref: ${{ steps.choose.outputs.ref }}
tag_suffix: ${{ steps.choose.outputs.tag_suffix }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x
- name: Get latest commit hash
id: choose
run: |
set -eo pipefail
.github/tools/get-nightly-ref.ts
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_REPOSITORY: ${{ github.repository }}
deploy:
runs-on: self-hosted
needs: get-ref
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ needs.get-ref.outputs.ref }}
- name: Download executable with curl
run: |
curl -L -o datex.zip https://github.com/unyt-org/datex-cli/releases/download/nightly/datex-x86_64-unknown-linux-gnu.zip
unzip datex.zip -d datex-bin
chmod +x ./datex-bin/datex
rm -rf datex.zip
- name: Run datex process in background
run: |
echo "Killing any existing DATEX processes..."
pids=$(ps -ef | grep '[d]atex' | awk '{print $2}')
if [ -n "$pids" ]; then
kill -9 $pids
fi
echo "Cleaning up old logs..."
[ -f ./datex.log ] && rm ./datex.log
echo "Starting DATEX in background..."
/home/docker/shared/bg.sh ./datex-bin/datex repl -v --config example-config.dx > ./datex.log 2>&1 &
sleep 2
pids=$(ps -ef | grep '[d]atex' | awk '{print $2}')
if [ -z "$pids" ]; then
echo "❌ DATEX did not start. Check ./datex.log for details."
else
echo "✅ DATEX started with PID: $pids"
fi