Skip to content

GitHub Action Automated Deployment (Recommended for Developers)

If you want higher control, version traceability, or need to manage the Cloudflare D1 database more precisely, GitHub Action is the most robust choice.


🛠️ Deployment Steps

1. Preparation (D1 Database)

Create a database named nodeauth-db in the Cloudflare dashboard and record its Database ID.

  • Go to Storage & Databases -> D1 -> Create Database.
Click to view: Detailed steps to create D1 SQL Databaseimage
image
image

2. Obtain API Token

  1. Log in to the Cloudflare Dashboard.
  2. Go here to get your token.
  3. Click "Create Token".
  4. Select the "Edit Cloudflare Workers" template.
  5. Configure "Account Resources" and "Zone Resources".
  6. Click "Continue to summary," then click "Create Token".
  7. Copy the generated token.
Click to view: Detailed steps to obtain a Cloudflare Worker deployment tokenimage
image

3. Configure Repository Secrets

This is the most critical step; never write your core keys directly into your code.

  1. Go to your GitHub project, click "Settings" -> "Secrets and variables" -> "Actions".
  2. Click "New repository secret" and add the following sequentially:
Secret NameSource / Recommended Value
CLOUDFLARE_API_TOKENThe API token you just generated in Cloudflare
CLOUDFLARE_ACCOUNT_IDThe Account ID displayed on the right side of the Cloudflare Workers dashboard
CLOUDFLARE_D1_DATABASE_IDThe ID of the nodeauth-db you just created
CLOUDFLARE_D1_DATABASE_NAMEnodeauth-db
ENCRYPTION_KEYA random key of at least 32 characters
JWT_SECRETA random key of at least 32 characters
OAUTH_ALLOWED_USERSYour allowed login email addresses
OAuth Secrets (Example)Refer to Login Platform Configuration for details
OAUTH_GITHUB_CLIENT_IDYour GitHub Client ID
OAUTH_GITHUB_CLIENT_SECRETYour GitHub Client Secret
OAUTH_GITHUB_REDIRECT_URIhttps://your-domain.com/oauth/callback
Click to view: Secrets Configuration ExampleSecrets Configuration Example

4. Trigger Deployment

  • Initial Deployment: Click "Actions" at the top of the project, select the Deploy to Cloudflare Workers workflow, and click "Run workflow".
  • Subsequent Updates: Every time you push code to the main branch, GitHub will automatically complete the deployment and sync the database for you.
Click to view: Manual Deployment Trigger ExampleManual Deployment Trigger

💡 Why Choose GitHub Action?

  • Transparent Deployment: Every deployment has log records, making errors clear at a glance.
  • Secure Secrets: All keys are stored with high-strength encryption by GitHub. Even if the repository is made public, the keys remain protected.
  • Continuous Integration: Automated testing and preview mechanisms ensure that the code you push is always functional.

Open sourced under GNU AGPL v3 License