Skip to content

GitHub Action Automated Deployment (Recommended for Developers) ​

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


📋 Deployment Prerequisites ​

  • License Code: Required to start the system, obtain it from the License Center.
  • GitHub Account: Used for hosting source code and running Action CI.
  • Cloudflare Account: Provides the Worker runtime environment and generates API tokens.
  • CF Hosted Domain (Optional): If you want to bind a custom domain, it must be hosted on CF (otherwise, *.workers.dev is assigned).

🛠️ 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 DatabaseOpen Storage and Databases in Cloudflare dashboard
Create a new Cloudflare D1 database
Name nodeauth-db and copy its Database ID

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 tokenSelect Edit Cloudflare Workers API token template
Configure account and zone resources to create Cloudflare API Token

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
NODEAUTH_LICENSESystem license code, obtain from license.nextmatrix.app/byos.
ENCRYPTION_KEYA random key of at least 32 characters, obtain from tools.nodeauth.io.
JWT_SECRETA random key of at least 32 characters, obtain from tools.nodeauth.io.
OAUTH_ALLOWED_USERSAllowed login list, e.g., your@example.com
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

⚙️ Advanced Custom Parameters (Optional) ​

If you also want to customize the Worker name or bind custom domains, add the optional Secrets below and the workflow will configure them automatically:

Secret NameDescriptionExample Value
CLOUDFLARE_WORKERS_NAMECustom name for the Worker deployed on Cloudflare (default is nodeauth-worker).my-2fa-server
CLOUDFLARE_WORKERS_ROUTESBind a custom domain. Format: request_path,domain_suffix (use semicolon ; to separate multiple routes). This requires your domain DNS to be managed by Cloudflare.2fa.example.com/*,example.com
CLOUDFLARE_WORKERS_DEVWhether to enable Cloudflare's default *.workers.dev domain. If you bind a custom domain and want to completely block access via the original domain, set this to false.false
CLOUDFLARE_WORKERS_PREVIEW_URLSWhether to enable URLs generated for preview branches, typically used for secondary development.true

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.