https://github.com/ramasilveyra/last-successful-gh-commit
Get last successful GitHub commit
https://github.com/ramasilveyra/last-successful-gh-commit
cd ci commit github jenkins status
Last synced: 3 months ago
JSON representation
Get last successful GitHub commit
- Host: GitHub
- URL: https://github.com/ramasilveyra/last-successful-gh-commit
- Owner: ramasilveyra
- License: mit
- Created: 2017-08-25T00:53:23.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2017-09-04T22:40:15.000Z (almost 9 years ago)
- Last Synced: 2025-10-19T21:43:30.408Z (9 months ago)
- Topics: cd, ci, commit, github, jenkins, status
- Language: JavaScript
- Homepage:
- Size: 45.9 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
Get last successful GitHub commit
last-successful-gh-commit
To achieve something similar to GIT_PREVIOUS_SUCCESSFUL_COMMIT env var defined by Git Plugin on Jenkins.
Table of Contents
- [Install](#install)
- [Example](#example)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)
Install
**Node.js v6.5 or newer** is required.
Via the yarn client:
```bash
$ yarn add --dev last-successful-gh-commit
```
Via the npm client:
```bash
$ npm install --save-dev last-successful-gh-commit
```
Example
```js
import getLastSuccessfulGHCommit from 'last-successful-gh-commit';
const owner = 'ramasilveyra';
const name = 'last-successful-gh-commit';
const token = process.env.GH_TOKEN;
getLastSuccessfulGHCommit({ owner, name, token })
.then(commit => {
console.log('Last successful commit: ', commit);
})
.catch(err => {
console.error('No successful commit found', err);
});
```
Usage
### getLastSuccessfulGHCommit(options)
### options
Type: `Object`
**Required**
### options.owner
Type: `string`
**Required**
Owner of the repository.
### options.name
Type: `string`
**Required**
Name of the repository.
### options.token
Type: `string`
**Required**
GitHub token with `repo` scope.
Contribute
Feel free to dive in! [Open an issue](https://github.com/ramasilveyra/last-successful-gh-commit/issues/new) or submit PRs.
last-successful-gh-commit follows the [Contributor Covenant](http://contributor-covenant.org/version/1/3/0/) Code of Conduct.
License
[MIT](LICENSE.md)