Skip to content

remove botton

remove botton #144

Workflow file for this run

name: Deploy Worker & Frontend to Cloudflare ☁️🚀
on:
push:
branches: [main]
workflow_dispatch:
jobs:
deploy-worker:
name: 🚀 Deploy Cloudflare Worker
runs-on: ubuntu-latest
outputs:
worker-url: ${{ steps.deploy_worker.outputs.url }}
auth-token: ${{ steps.gen_token.outputs.token }}
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 🧰 Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: 🔑 Generate AUTH_TOKEN
id: gen_token
run: |
# Generate token without newline
TOKEN=$(openssl rand -hex 32 | tr -d '\n')
echo "Generated token: ${TOKEN:0:5}..." # Partial for security
echo "token=$TOKEN" >> "$GITHUB_OUTPUT"
- name: 📥 Install Wrangler CLI
run: npm install -g wrangler@4
- name: 📝 Generate wrangler.toml with account_id
working-directory: worker
run: |
sed "s/__ACCOUNT_ID__/${{ secrets.CF_ACCOUNT_ID }}/g" wrangler.template.toml > wrangler.toml
- name: 🔐 Set secrets and deploy worker
working-directory: worker
id: deploy_worker
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CF_API_TOKEN }}
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
TMDB_API_KEY: ${{ secrets.TMDB_API_KEY }}
AUTH_TOKEN: ${{ steps.gen_token.outputs.token }}
run: |
# Push secrets without newlines
echo -n "$TELEGRAM_BOT_TOKEN" | wrangler secret put TELEGRAM_BOT_TOKEN
echo -n "$TMDB_API_KEY" | wrangler secret put TMDB_API_KEY
echo -n "$AUTH_TOKEN" | wrangler secret put AUTH_TOKEN
# Deploy worker
DEPLOY_OUTPUT=$(wrangler deploy)
echo "$DEPLOY_OUTPUT"
# Extract Worker URL
WORKER_URL=$(echo "$DEPLOY_OUTPUT" | grep -o 'https://[^ ]*\.workers\.dev' | head -n1)
echo "url=$WORKER_URL" >> "$GITHUB_OUTPUT"
deploy-frontend:
name: 🌐 Deploy Frontend to Cloudflare Pages
needs: deploy-worker
runs-on: ubuntu-latest
steps:
- name: 📦 Checkout code
uses: actions/checkout@v4
- name: 📝 Inject Worker URL
run: |
WORKER_URL="${{ needs.deploy-worker.outputs.worker-url }}"
sed -i "s|__WORKER_URL__|$WORKER_URL|g" public/script.js
echo "Worker URL injected: ${WORKER_URL:0:20}..."
- name: 📝 Inject Auth Token
run: |
AUTH_TOKEN="${{ needs.deploy-worker.outputs.auth-token }}"
sed -i "s|__AUTH_TOKEN__|$AUTH_TOKEN|g" public/script.js
echo "Token injected: ${AUTH_TOKEN:0:5}..."
- name: 🔍 Verify replacements
run: |
if grep -q "__WORKER_URL__" public/script.js; then
echo "❌ Worker URL replacement failed!"
exit 1
fi
if grep -q "__AUTH_TOKEN__" public/script.js; then
echo "❌ Token replacement failed!"
exit 1
fi
echo "✅ Replacements verified"
- name: 🔧 Deploy to Cloudflare Pages
uses: cloudflare/pages-action@1
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
projectName: imdb-tg-post-font
directory: ./public
branch: main