From 91a79e7ae1d5515c3e0f8fcda0770abf7925f03d Mon Sep 17 00:00:00 2001 From: tedspare Date: Tue, 18 Nov 2025 16:17:25 -0500 Subject: [PATCH] feat: add Railway deploy workflow and Bun server\n\n- Bun HTTP server listening on PORT\n- start script for Nixpacks\n- GitHub Action for Railway deploy --- .github/workflows/railway-deploy.yml | 36 ++++++++++++++++++++++++++++ index.ts | 13 +++++++++- package.json | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/railway-deploy.yml diff --git a/.github/workflows/railway-deploy.yml b/.github/workflows/railway-deploy.yml new file mode 100644 index 0000000..2550e7c --- /dev/null +++ b/.github/workflows/railway-deploy.yml @@ -0,0 +1,36 @@ +name: Deploy to Railway + +on: + push: + branches: [ "main" ] + workflow_dispatch: + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install Railway CLI + run: npm i -g @railway/cli + + - name: Deploy with Railway + env: + RAILWAY_TOKEN: ${{ secrets.RAILWAY_TOKEN }} + RAILWAY_PROJECT_ID: ${{ secrets.RAILWAY_PROJECT_ID }} + RAILWAY_SERVICE_ID: ${{ secrets.RAILWAY_SERVICE_ID }} + run: | + set -euo pipefail + PROJECT_FLAG="" + SERVICE_FLAG="" + if [ -n "${RAILWAY_PROJECT_ID:-}" ]; then PROJECT_FLAG="--project ${RAILWAY_PROJECT_ID}"; fi + if [ -n "${RAILWAY_SERVICE_ID:-}" ]; then SERVICE_FLAG="--service ${RAILWAY_SERVICE_ID}"; fi + # Deploy current repo; --yes to skip prompts + railway up $PROJECT_FLAG $SERVICE_FLAG --yes + diff --git a/index.ts b/index.ts index f67b2c6..94be617 100644 --- a/index.ts +++ b/index.ts @@ -1 +1,12 @@ -console.log("Hello via Bun!"); \ No newline at end of file +const port = Number(process.env.PORT || 3000); + +const server = Bun.serve({ + port, + fetch(_req) { + return new Response("Hello via Bun!", { + headers: { "content-type": "text/plain; charset=utf-8" }, + }); + }, +}); + +console.log(`Server running on http://localhost:${server.port}`); diff --git a/package.json b/package.json index 81cba48..3196d02 100644 --- a/package.json +++ b/package.json @@ -3,6 +3,9 @@ "module": "index.ts", "type": "module", "private": true, + "scripts": { + "start": "bun run index.ts" + }, "devDependencies": { "@types/bun": "latest" },