# deploy-pr-action

> Deploy every pull request to a static URL

Latest version **1.5.0** (published 2020-09-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install deploy-pr-action
pnpm add deploy-pr-action
yarn add deploy-pr-action
bun add deploy-pr-action
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.0 |
| Published | 2020-09-08 |
| First published | 2020-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 806.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Anand Chowdhary |
| Maintainers | anandchowdhary |
| Keywords | github, github actions, nodejs, typescript, starter |

## Links

- npm: https://www.npmjs.com/package/deploy-pr-action
- Repository: https://github.com/koj-co/deploy-pr-action
- Homepage: https://github.com/koj-co/deploy-pr-action#readme
- Issues: https://github.com/koj-co/deploy-pr-action/issues
- npm.io page: https://npm.io/package/deploy-pr-action

## Dependencies (4)

- [fs-extra](https://npm.io/package/fs-extra.md) ^9.0.1
- [@actions/core](https://npm.io/package/@actions/core.md) ^1.2.4
- [@actions/github](https://npm.io/package/@actions/github.md) ^4.0.0
- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) ^1.1.0

## Alternatives

- [@openai/codex-sdk](https://npm.io/package/@openai/codex-sdk.md) — 731.4K weekly downloads
- [babel-plugin-transform-react-jsx](https://npm.io/package/babel-plugin-transform-react-jsx.md) — 565.0K weekly downloads
- [babel-helper-remove-or-void](https://npm.io/package/babel-helper-remove-or-void.md) — 508.5K weekly downloads
- [@pnpm/store-controller-types](https://npm.io/package/@pnpm/store-controller-types.md) — 186.9K weekly downloads
- [react-native-signature-canvas](https://npm.io/package/react-native-signature-canvas.md) — 155.6K weekly downloads

## Recent versions

- 1.5.0 (latest) — 2020-09-08
- 1.4.1 — 2020-08-26
- 1.4.0 — 2020-08-17
- 1.3.2 — 2020-08-17
- 1.3.1 — 2020-08-17
- 1.3.0 — 2020-08-17
- 1.2.2 — 2020-08-17
- 1.2.1 — 2020-08-17
- 1.2.0 — 2020-08-17
- 1.1.0 — 2020-08-17
- 1.0.1 — 2020-08-17
- 1.0.0 — 2020-08-17

## README

# 🚀🎬 Deploy PR Action

This is a GitHub Action that automatically deploys all pull requests and branches as a static site using [Surge.sh](https://surge.sh).

[![Test CI](https://github.com/koj-co/deploy-pr-action/workflows/Test%20CI/badge.svg)](https://github.com/koj-co/deploy-pr-action/actions?query=workflow%3A%22Test+CI%22)
[![Release CI](https://github.com/koj-co/deploy-pr-action/workflows/Release%20CI/badge.svg)](https://github.com/koj-co/deploy-pr-action/actions?query=workflow%3A%22Release+CI%22)
[![Node CI](https://github.com/koj-co/deploy-pr-action/workflows/Node%20CI/badge.svg)](https://github.com/koj-co/deploy-pr-action/actions?query=workflow%3A%22Node+CI%22)

## ⭐ Features

- Auto-deploy every PR and branch to its unique environment
- Unlimited free static site deployments, thanks to [Surge.sh](https://surge.sh)
- No search engine indexing for branch sites (`robots.txt` injection)
- Label and comment on PRs with the deployment and log URLs
- Update your staging GitHub environment status

## ⚙️ Usage

### Inputs

#### `distDir` (required)

The directory to deploy, for example `dist` or `public`

#### `prefix`

Prefix for deployment URL, e.g., `example` will translate to https://example-PR_NAME.surge.sh

#### `robotsTxtPath`

Generate a `robots.txt` file to prevent search engines from indexing the deployment

#### `robotsContent`

Content for `robots.txt` file, defaults to:

```txt
User-agent: *
Disallow: /
```

#### `environmentName`

Name of the deployment environment on GitHub, defaults to "Preview"

#### `skipComment`

Skip adding the deployment details comment, defaults to `false`

#### `skipLabels`

Skip adding the labels to pull requests, defaults to `false`

#### `labels`

Labels to add to pull requests as a comma-separated list, defaults to `deployed`

### Environment variables

#### `GITHUB_TOKEN` (required)

The GitHub token is required to add labels, comments, etc., on the PR: `GITHUB_TOKEN: ${{ secrets.GH_PAT }}`

#### `SURGE_LOGIN` (required)

Your Surge.sh email address, required to deploy site to Surge.sh

#### `SURGE_TOKEN` (required)

Your Surge.sh login token, required to deploy site to Surge.sh (get it by doing `surge token`)

### Example

```yaml
name: Deploy CI
on:
  issue_comment:
    types: [created]
  push:
    branches-ignore:
      - master
  pull_request:
    types:
      - opened
      - edited
      - synchronize
jobs:
  release:
    name: Deploy website
    runs-on: ubuntu-18.04
    if: "!contains(github.event.head_commit.message, '[skip ci]') && (contains(github.event.comment.body, 'Deploy') || contains(github.event.comment.body, 'deploy') || github.event_name == 'push' || github.event_name == 'pull_request')"
    steps:
      - name: Checkout
        uses: actions/checkout@v1
      - name: Setup Node.js
        uses: actions/setup-node@v1
        with:
          node-version: 12
      - name: Install dependencies
        run: npm ci
      - name: Build static site
        run: npm run build # Build your website
      - name: Deploy
        uses: koj-co/deploy-pr-action@v1.0.1
        with:
          prefix: example # Prefix for deployment URL
          robotsTxtPath: dist/robots.txt # Add robots.txt file
          distDir: dist # Path to dist directory
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # GitHub token
          SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} # Surge.sh email
          SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} # Surge.sh token
```

## 📄 License

- Code: [MIT](./LICENSE) © [Koj](https://koj.co)
- "GitHub" is a trademark of GitHub, Inc.

<p align="center">
  <a href="https://koj.co">
    <img width="44" alt="Koj" src="https://kojcdn.com/v1598284251/website-v2/koj-github-footer_m089ze.svg">
  </a>
</p>
<p align="center">
  <sub>An open source project by <a href="https://koj.co">Koj</a>. <br> <a href="https://koj.co">Furnish your home in style, for as low as CHF175/month →</a></sub>
</p>

---
_Source: https://npm.io/package/deploy-pr-action · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
