# deploy-repo

> Watch for push events to git branches

Latest version **1.0.1** (published 2024-03-25) · MIT license · 0 weekly downloads

## Install

```sh
npm install deploy-repo
pnpm add deploy-repo
yarn add deploy-repo
bun add deploy-repo
```

Provides the command `deploy-repo`.

## 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.0.1 |
| Published | 2024-03-25 |
| First published | 2024-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 7.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 1337 |
| Maintainers | lukks |

## Links

- npm: https://www.npmjs.com/package/deploy-repo
- Repository: https://github.com/like/deploy-repo
- Homepage: https://github.com/like/deploy-repo#readme
- Issues: https://github.com/like/deploy-repo/issues
- npm.io page: https://npm.io/package/deploy-repo

## Dependencies (3)

- [minimist](https://npm.io/package/minimist.md) ^1.2.8
- [like-fetch](https://npm.io/package/like-fetch.md) ^2.2.0
- [localdrive](https://npm.io/package/localdrive.md) ^1.11.4

## Recent versions

- 1.0.1 (latest) — 2024-03-25
- 1.0.0 — 2024-03-16

## README

# deploy-repo

Watch for push events to git branches

```
npm i -g deploy-repo
```

## Usage

Default server `https://deploy.leet.ar/v1`

Configurable via env `API_URL` in case you self-host your own backend.

#### 1. Create a deploy account

```sh
deploy-repo create
```

It will print an `id` and `secret`. Also, it creates a `~/.deploy` folder.

Protect the account id, it gives read/delete capabilities on the API.

#### 2. Go to repository settings -> Webhooks -> Add webhook

- Set `Payload URL` to `https://deploy.leet.ar/v1/webhooks/<account-id>`
- Set `Content type` to `application/json`.
- Set `Secret` to the corresponding value.

Discard the `secret` value now, unless you reuse it for several repos then discard it.

#### 3. Watch for changes on the server where you have the repository

```sh
deploy-repo watch like/example#main --script ./reload.sh --id <account-id>
```

## API

```sh
deploy-repo create
deploy-repo list
deploy-repo delete <account-id>
deploy-repo watch <owner/repo#branch> --script <filename> --id <account-id>
```

## Example script

```sh
#!/bin/bash

# Naive way to update the git repo
PK="/home/user/.ssh/id_example_backend"
GIT_SSH_COMMAND="ssh -i $PK -o IdentitiesOnly=yes" git pull
npm i

# Reload the service
PID=$(systemctl show --property MainPID --value example-backend)
/bin/kill -s INT $PID
```

## License

MIT

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