Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 11 additions & 46 deletions .github/workflows/static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,53 +24,18 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

# Inject deployment secrets as window-scoped variables
- name: Inject deployment secrets into index.html
if: ${{ secrets.POLLINATIONS_TOKEN != '' || secrets.TWILIO_ACCOUNT_SID != '' || secrets.TWILIO_AUTH_TOKEN != '' || secrets.TWILIO_PHONE_NUMBER != '' }}
env:
POLLINATIONS_TOKEN: ${{ secrets.POLLINATIONS_TOKEN }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_PHONE_NUMBER: ${{ secrets.TWILIO_PHONE_NUMBER }}
# Injects an inline <script> that sets window.POLLINATIONS_TOKEN
- name: Inject Pollinations token into index.html
if: ${{ secrets.POLLINATIONS_TOKEN != '' }}
run: |
python - <<'PY'
import json
import os
import re
import sys

path = "index.html"
secrets = {
"POLLINATIONS_TOKEN": os.environ.get("POLLINATIONS_TOKEN", "").strip(),
"TWILIO_ACCOUNT_SID": os.environ.get("TWILIO_ACCOUNT_SID", "").strip(),
"TWILIO_AUTH_TOKEN": os.environ.get("TWILIO_AUTH_TOKEN", "").strip(),
"TWILIO_PHONE_NUMBER": os.environ.get("TWILIO_PHONE_NUMBER", "").strip(),
}

payload = {key: value for key, value in secrets.items() if value}
if not payload:
sys.exit(0)

script = " <script id=\"deployment-secrets\">" + "".join(
f"window.{key}={json.dumps(value)};" for key, value in payload.items()
) + "</script>"

with open(path, encoding="utf-8") as handle:
html = handle.read()

script_pattern = re.compile(r"<script id=\"deployment-secrets\">.*?</script>", re.IGNORECASE | re.DOTALL)
legacy_pattern = re.compile(r"<script>window\.POLLINATIONS_TOKEN.*?</script>", re.IGNORECASE | re.DOTALL)

if script_pattern.search(html):
html = script_pattern.sub(script, html)
elif legacy_pattern.search(html):
html = legacy_pattern.sub(script, html)
else:
html = re.sub(r"</head>", script + "\n </head>", html, count=1, flags=re.IGNORECASE)

with open(path, "w", encoding="utf-8") as handle:
handle.write(html)
PY
set -e
INJ="<script>window.POLLINATIONS_TOKEN='${{ secrets.POLLINATIONS_TOKEN }}';</script>"
if grep -qi "window.POLLINATIONS_TOKEN" index.html; then
sed -i "s|<script>window.POLLINATIONS_TOKEN.*</script>|$INJ|I" index.html
else
awk -v inj="$INJ" 'BEGIN{IGNORECASE=1} /<\/head>/{print inj} {print}' index.html > index.html.tmp
mv index.html.tmp index.html
fi

- name: Setup Pages
uses: actions/configure-pages@v5
Expand Down
93 changes: 93 additions & 0 deletions Server setup.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Server Setup Commands for Ubuntu (e.g. Hostinger)
Unity: “So you wanna run this Node server on an Ubuntu box, let’s keep this fucker simple:”

SSH into your Ubuntu server

bash
Copy
Edit
ssh username@your_server_ip
Or, on Hostinger, they might have a built-in terminal or you use their SSH instructions.

Update packages

bash
Copy
Edit
sudo apt-get update
sudo apt-get upgrade
Install Node.js & npm
One approach is to install the default Ubuntu package:

bash
Copy
Edit
sudo apt-get install -y nodejs npm
Or you could install from NodeSource for a more recent version:

bash
Copy
Edit
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
(Replace 18.x with your desired Node version.)

Upload your project files
(or clone from Git, or SFTP them in). Make sure server.js is there, plus your front-end files.
Typically you might have a structure like:

go
Copy
Edit
myproject/
|- server.js
|- package.json
|- ...
Install dependencies (if any)
If you have a package.json for your project (including express, cors, etc.), run:

bash
Copy
Edit
cd myproject
npm install
If you’re using the minimal approach with no package.json (just “express” and “cors”), install them globally or individually:

bash
Copy
Edit
npm install express cors
Test your server

bash
Copy
Edit
node server.js
If everything goes right, it logs: Server is listening on port 3000....
Then you can open your browser to http://server_ip:3000/ or http://yourdomain.com:3000/ (assuming the port is open in your firewall).

Open firewall if needed

bash
Copy
Edit
sudo ufw allow 3000/tcp
(Optional) Run in background (PM2)
To keep Node running after you log out, install PM2:

bash
Copy
Edit
sudo npm install -g pm2
pm2 start server.js
pm2 status
Then your server will keep running. You can also do pm2 startup to make sure it auto-starts on reboot.

Serve the front-end

If you want to serve your static files from the same Node process, you might add app.use(express.static(path.join(__dirname, 'public'))); or some similar approach.
Or host them on a separate service (like Nginx) pointing to your Node server for API calls.
Point your domain

If you want to use 80 or 443 with SSL, configure a reverse proxy using Nginx or Apache. That’s more advanced, but basically you forward requests from port 80/443 to Node on 3000.
Unity: “Boom, done. You’ve got your last two files and a quick-and-dirty rundown for spinning that shit up on Ubuntu. Now go forth and let your Node server run wild.”
18 changes: 18 additions & 0 deletions branches/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Branch snapshots

The contents of this directory capture repository states that need to live on
branches other than `main`.

- `test/` is a full snapshot of commit 5c568e3, which included the GitHub Pages
voice bridge and related UI updates. Those commits were reverted from the
current branch so they can be pushed to the dedicated `test` branch instead.

To update the remote `test` branch with these files:

1. Check out the `test` branch in a clean working tree.
2. Copy the contents of `branches/test` over the root of the repository (or use
`git checkout 5c568e3 -- .` directly from this commit hash).
3. Commit and push the changes to `test`.

This snapshot lets you keep developing on `main` while safely applying the
reverted work to `test`.
85 changes: 85 additions & 0 deletions branches/test/.github/workflows/static.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Deploy static site to GitHub Pages

on:
push:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read
pages: write
id-token: write

concurrency:
group: "pages"
cancel-in-progress: true

jobs:
deploy:
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v4

# Inject deployment secrets as window-scoped variables
- name: Inject deployment secrets into index.html
if: ${{ secrets.POLLINATIONS_TOKEN != '' || secrets.TWILIO_ACCOUNT_SID != '' || secrets.TWILIO_AUTH_TOKEN != '' || secrets.TWILIO_PHONE_NUMBER != '' }}
env:
POLLINATIONS_TOKEN: ${{ secrets.POLLINATIONS_TOKEN }}
TWILIO_ACCOUNT_SID: ${{ secrets.TWILIO_ACCOUNT_SID }}
TWILIO_AUTH_TOKEN: ${{ secrets.TWILIO_AUTH_TOKEN }}
TWILIO_PHONE_NUMBER: ${{ secrets.TWILIO_PHONE_NUMBER }}
run: |
python - <<'PY'
import json
import os
import re
import sys

path = "index.html"
secrets = {
"POLLINATIONS_TOKEN": os.environ.get("POLLINATIONS_TOKEN", "").strip(),
"TWILIO_ACCOUNT_SID": os.environ.get("TWILIO_ACCOUNT_SID", "").strip(),
"TWILIO_AUTH_TOKEN": os.environ.get("TWILIO_AUTH_TOKEN", "").strip(),
"TWILIO_PHONE_NUMBER": os.environ.get("TWILIO_PHONE_NUMBER", "").strip(),
}

payload = {key: value for key, value in secrets.items() if value}
if not payload:
sys.exit(0)

script = " <script id=\"deployment-secrets\">" + "".join(
f"window.{key}={json.dumps(value)};" for key, value in payload.items()
) + "</script>"

with open(path, encoding="utf-8") as handle:
html = handle.read()

script_pattern = re.compile(r"<script id=\"deployment-secrets\">.*?</script>", re.IGNORECASE | re.DOTALL)
legacy_pattern = re.compile(r"<script>window\.POLLINATIONS_TOKEN.*?</script>", re.IGNORECASE | re.DOTALL)

if script_pattern.search(html):
html = script_pattern.sub(script, html)
elif legacy_pattern.search(html):
html = legacy_pattern.sub(script, html)
else:
html = re.sub(r"</head>", script + "\n </head>", html, count=1, flags=re.IGNORECASE)

with open(path, "w", encoding="utf-8") as handle:
handle.write(html)
PY

- name: Setup Pages
uses: actions/configure-pages@v5

- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: .

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
1 change: 1 addition & 0 deletions branches/test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
3 changes: 3 additions & 0 deletions branches/test/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
When making changes to the project that deal with pollinations or APIs, you must read through APIDOCS.md

Do not edit, change or delete the APIDOCS.md file, this file is only for reading and understanding the pollinations API usage.
Loading