# gitlab-autodeploy

> Autodeploy utility

Latest version **0.1.9** (published 2017-12-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install gitlab-autodeploy
pnpm add gitlab-autodeploy
yarn add gitlab-autodeploy
bun add gitlab-autodeploy
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.9 |
| Published | 2017-12-19 |
| First published | 2017-11-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=8.4.0 |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Marcos Cesar Gritti |
| Maintainers | gritti |

## Links

- npm: https://www.npmjs.com/package/gitlab-autodeploy
- Repository: https://github.com/pkcgritti/autodeploy
- Homepage: https://github.com/MCGritti/autodeploy#readme
- Issues: https://github.com/MCGritti/autodeploy/issues
- npm.io page: https://npm.io/package/gitlab-autodeploy

## Dependencies (4)

- [https](https://npm.io/package/https.md) ^1.0.0
- [express](https://npm.io/package/express.md) ^4.16.2
- [messenger](https://npm.io/package/messenger.md) 0.0.9
- [body-parser](https://npm.io/package/body-parser.md) ^1.18.2

## Recent versions

- 0.1.9 (latest) — 2017-12-19
- 0.1.8 — 2017-12-03
- 0.1.7 — 2017-12-03
- 0.1.6 — 2017-12-03
- 0.1.5 — 2017-12-03
- 0.1.4 — 2017-12-03
- 0.1.3 — 2017-11-30
- 0.1.2 — 2017-11-30
- 0.1.1 — 2017-11-30
- 0.1.0 — 2017-11-30

## README

# gitlab-autodeploy
Handle gitlab post requests easier.

## Autodeploy server example
Create an index.js in your 'adserver' with
```js
const ad = require('gitlab-autodeploy')
const { repositoryIsUpdated, execOn } = ad.utils

ad.configServer({
  expressHostname: 'my.domain.com', // Domain to be used in gitlab hook config
  expressPostUrl: '/',              // Route used to listen post's from gitlab
  expressPort: 8000,                // Express port
  tcpPort: 9000,                    // Tcp port (to comunicate with other local servers)
  secretToken: 'someSecretToken'    // Received as x-gitlab-token header
})

ad.listen()

const repoNamePath = '/var/node/repoName'

// Handling a post from gitlab for repo 'repoName' 
ad.on('repoName', (payload, done) => {
  (async () => {
    if (await repositoryIsUpdated(repoNamePath)) {
      console.log('Repository already up to date')
    } else {
      console.log('Applying some changes')
      if (foo(payload)) {
        // Check something in payload
      }
      await execOn(repoNamePath, 'git fetch && get merge')
      done() // This must be called at the end
    }
  })()
})
```

## Configuring your express application
Register gitlab-autodeploy in your application with
```js
const express = require('express')
const app = express()

//
// Import and configure your modules
//

// Import and configure gitlab-autodeploy
const ad = require('gitlab-autodeploy')
ad.configClient({
  tcpPort: 9000,
  busyRoute: (req, res, next) => {
    // Make something when autodeploy is busy
  }
})
const adclient = ad.createClientRoute()

// And finally, use it in your application
// to comunicate with the autodeploy server.
app.use(adclient)
```
Further information will be added in the next weeks.

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