跳到正文

Wrangler Action

维护中
cloudflare/wrangler-action

使用 Wrangler 部署 Cloudflare Workers 和 Pages 应用的 GitHub Action,与 GitHub CI/CD 工作流无缝集成,支持定时部署,并可处理生产和预览环境。

在 GitHub 查看
星标
1886
Fork
211
关注
1886
未关闭 Issue
52

该介绍目前仅提供英文版本。

A GitHub Action for deploying Cloudflare Workers and Pages applications using Wrangler, enabling seamless integration with your GitHub CI/CD workflows.

Key Features

  • Simplified Deployment: Deploy Workers applications with minimal configuration
  • Pages Support: Deploy both production and preview environments for Cloudflare Pages
  • Flexible Triggers: Deploy on push, schedule, or manual triggers
  • Version Management: Support for creating and managing Worker versions
  • Secret Management: Securely handle environment-specific secrets
  • Multiple Package Managers: Support for npm, yarn, pnpm, and Bun
  • Command Output Access: Capture deployment outputs for use in subsequent workflow steps
  • Automatic Detection: Smart detection of project structure and configuration

Basic Usage

Add this workflow to your project to deploy on every push to the main branch:

name: Deploy

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    name: Deploy
    steps:
      - uses: actions/checkout@v4
      - name: Deploy
        uses: cloudflare/wrangler-action@v3
        with:
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}

Advanced Deployment Options

The action supports various deployment scenarios:

  • Pages Deployments: Deploy Pages projects with automatic preview/production detection
  • Scheduled Deployments: Run deployments on a recurring basis using cron syntax
  • Manual Triggers: Deploy on-demand with configurable workflow inputs
  • Worker Versions: Create Worker versions without immediate deployment
  • Environment-specific Configuration: Target specific environments with customized settings

Integration with GitHub Features

Wrangler Action integrates well with GitHub’s ecosystem:

  • GitHub Deployments: Track deployments in the GitHub UI
  • Workflow Dispatch: Trigger deployments manually with parameters
  • Output Variables: Access deployment URLs and command outputs in subsequent steps
  • Secrets Management: Securely store and use sensitive credentials

When to Use

  • When automating deployments of Cloudflare Workers applications
  • When building CI/CD pipelines for Cloudflare Pages projects
  • When you need environment-specific deployments (dev, staging, production)
  • When you want scheduled or manual deployment options
  • When you need to capture and utilize deployment results within your workflow

Frequently Asked Questions

How do I set up authentication?

Create a Cloudflare API token with the appropriate permissions, then add it to your GitHub repository secrets.

Can I deploy to different environments?

Yes, use the command parameter with the --env flag to specify the target environment.

How do I handle environment-specific secrets?

Use the secrets parameter along with the environment parameter to provide environment-specific values.

Does this work with package managers other than npm?

Yes, the action automatically detects your package manager based on lock files, or you can explicitly specify it using the packageManager parameter.

按共同分类和标签排序的同类开源项目。

全部 DevOps 项目 →