|
| 1 | +# CLAUDE.md |
| 2 | + |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +This is a GitHub Action that deploys projects to Vercel. It's an npm package that integrates with GitHub workflows to automate deployments, providing more control than Vercel's native GitHub integration. |
| 8 | + |
| 9 | +## Essential Commands |
| 10 | + |
| 11 | +### Development |
| 12 | +```bash |
| 13 | +npm install # Install dependencies |
| 14 | +npm start # Run the action locally (node ./index.js) |
| 15 | +npm run lint # Run ESLint on index.js |
| 16 | +npm run format # Format code with Prettier |
| 17 | +npm run format-check # Check code formatting |
| 18 | +npm test # Run Jest tests |
| 19 | +npm run all # Run format, lint, package, and test in sequence |
| 20 | +``` |
| 21 | + |
| 22 | +### Building for Distribution |
| 23 | +```bash |
| 24 | +npm run package # Build the action with ncc (outputs to dist/) |
| 25 | +``` |
| 26 | + |
| 27 | +**Important**: The `dist/` folder must be committed when creating releases. This contains the bundled action code that GitHub Actions will execute. |
| 28 | + |
| 29 | +## Architecture |
| 30 | + |
| 31 | +### Core Components |
| 32 | + |
| 33 | +1. **index.js**: Main entry point that: |
| 34 | + - Reads GitHub Action inputs (vercel-token, github-token, etc.) |
| 35 | + - Executes Vercel CLI commands for deployment |
| 36 | + - Comments on PRs/commits with deployment URLs |
| 37 | + - Handles alias domain assignment |
| 38 | + - Manages environment variables for Vercel org/project |
| 39 | + |
| 40 | +2. **action.yml**: Defines the GitHub Action interface: |
| 41 | + - Input parameters configuration |
| 42 | + - Output values (preview-url, preview-name) |
| 43 | + - Runtime environment (Node.js 20) |
| 44 | + |
| 45 | +### Key Dependencies |
| 46 | +- `@actions/core`: GitHub Actions toolkit for inputs/outputs |
| 47 | +- `@actions/exec`: Execute shell commands |
| 48 | +- `@actions/github`: GitHub API interactions |
| 49 | +- `vercel`: CLI for deployments |
| 50 | +- `axios`: HTTP requests for alias management |
| 51 | + |
| 52 | +### Deployment Flow |
| 53 | +1. Action reads configuration from inputs and environment |
| 54 | +2. Sets up Vercel org/project IDs from `.vercel/` directory |
| 55 | +3. Executes `vercel` command with appropriate flags |
| 56 | +4. Parses deployment URL from output |
| 57 | +5. Optionally assigns alias domains |
| 58 | +6. Comments on GitHub PR/commit with deployment info |
| 59 | + |
| 60 | +## Testing Approach |
| 61 | + |
| 62 | +- Jest is configured but tests are minimal (index.test.js is empty) |
| 63 | +- Manual testing through example projects in `example/` directory |
| 64 | +- GitHub Actions workflows test different scenarios |
| 65 | + |
| 66 | +## Important Conventions |
| 67 | + |
| 68 | +1. **Vercel Configuration**: Projects must have `github.enabled: false` in vercel.json |
| 69 | +2. **Project Linking**: The `.vercel/` directory with org/project IDs must be committed |
| 70 | +3. **Build Process**: Builds should happen in GitHub Actions, not Vercel |
| 71 | +4. **Backward Compatibility**: Maintain support for deprecated "zeit-" prefixed inputs |
| 72 | +5. **Error Handling**: Use proper exit codes and clear error messages for CI/CD integration |
0 commit comments