Deploy example endpoint #56
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
sleep 2 | |
echo "✅ DATEX started successfully." |