Skip to content
This repository has been archived by the owner on Dec 21, 2020. It is now read-only.

Commit

Permalink
feat(ci): add semantic-release and docker
Browse files Browse the repository at this point in the history
  • Loading branch information
cyberhck committed Jul 16, 2019
1 parent 90186cf commit 9d3d0ac
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 14 deletions.
7 changes: 5 additions & 2 deletions .github/pricacy_policy.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Privacy Policy

Nishchal Gautam ("Me", "Myself", and "I") built Handlebar Templates (the "app") as an Open Source GitHub App. This service is provided by myself and is intended for use as is.
Nishchal Gautam ("Me", "Myself", and "I") built `Merge When Ready` (the "app") as an Open Source GitHub App. This service is provided by myself and is intended for use as is.

This page is used to inform users ("you") regarding my policies with the collection, use, and disclosure of personal information if anyone decided to use this service.

Expand All @@ -12,8 +12,11 @@ When installing the the app you grant it access to the following three scopes

1. **Read & write access to [pull requests] and [issues]**

The app simply runs handlebar templates with some variables given to us by github and updates body
The app simply listen for events from github, checks if PR is ready to be merged.

2. **Read & write access to repository contents**

The app when detects PR is ready to merge, it issues a merge command

## Sharing of data with 3rd party services

Expand Down
13 changes: 6 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
dist: trusty
language: node_js
services: docker

node_js:
- "10"
- "12"

before_install:
- npm install -g greenkeeper-lockfile@1
- npm i @semantic-release/exec

before_script: greenkeeper-lockfile-update

script:
- npm run build -s
- npm run test -s
- npm run lint -s
- docker build . -t fossapps/merge-when-ready
- npx semantic-release

after_success:
- bash <(curl -s https://codecov.io/bash)

deploy:
provider: script
script: "./scripts/deploy.sh"
skip_cleanup: true

8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM node:12-alpine
MAINTAINER fossapps gautam.nishchal@gmail.com
WORKDIR /app
ADD node_modules ./node_modules
ADD ./lib ./lib
EXPOSE 3000
ADD package.json ./package.json
CMD ["node", "./lib/server.js"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[![dependencies Status](https://david-dm.org/fossapps/MergeWhenReady/status.svg)](https://david-dm.org/fossapps/MergeWhenReady)
[![codecov](https://codecov.io/gh/fossapps/MergeWhenReady/branch/master/graph/badge.svg)](https://codecov.io/gh/fossapps/MergeWhenReady)

Github app to run your issue body and pull request's body through handlebar to generate new bodies
Github app to automatically merge your PRs when they're ready

- Typescript 3.x
- Automatically deploys to now.sh
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"coverageDirectory": "<rootDir>/coverage",
"coveragePathIgnorePatterns": [
"index.ts",
"AppConfig.ts"
"AppConfig.ts",
"server.ts"
],
"testRegex": "(/__tests__/.*|\\.(test|spec))\\.(ts|tsx)$",
"moduleFileExtensions": [
Expand Down
61 changes: 61 additions & 0 deletions release.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
class SemanticReleaseError extends Error {
constructor(message, code, details) {
super(message);
Error.captureStackTrace(this, this.constructor);
this.name = 'SemanticReleaseError';
this.details = details;
this.code = code;
this.semanticRelease = true;
}
}

module.exports = {
verifyConditions: [
() => {
if (!process.env.DOCKERHUB_LOGIN) {
throw new SemanticReleaseError(
"No DOCKERHUB_LOGIN specified",
"ENODOCKERHUB_LOGIN",
"Please make sure to add docker hub user in `DOCKERHUB_LOGIN` environment variable on your CI environment. The token must be able to push docker image");
}
if (!process.env.GH_TOKEN) {
throw new SemanticReleaseError(
"No GH_TOKEN specified",
"ENOGH_TOKEN",
"Please make sure to github token in `GH_TOKEN` environment variable on your CI environment. The token must be able to create releases");
}
if (!process.env.DOCKERHUB_PASSWORD) {
throw new SemanticReleaseError(
"No DOCKERHUB_PASSWORD specified",
"ENODOCKERHUB_PASSWORD",
"Please make sure to add docker password in `DOCKERHUB_PASSWORD` environment variable on your CI environment.");
}
},
"@semantic-release/github"
],
prepare: [
{
path: "@semantic-release/exec",
cmd: "docker tag fossapps/merge-when-ready:latest fossapps/merge-when-ready:${nextRelease.version}"
},
{
path: "@semantic-release/exec",
cmd: "echo \"$DOCKERHUB_PASSWORD\" | docker login -u \"$DOCKERHUB_LOGIN\" --password-stdin"
}
],
publish: [
{
path: "@semantic-release/exec",
cmd: "docker push fossapps/merge-when-ready"
},
{
path: "@semantic-release/exec",
cmd: "docker push fossapps/merge-when-ready:${nextRelease.version}"
},
{
path: "@semantic-release/exec",
cmd: "./scripts/deploy.sh"
},
"@semantic-release/github"
]
};
4 changes: 1 addition & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@ const appConfig = getAppConfig();
const probot = new Probot(appConfig);
probot.load(App.handle);

probot.start();

// tslint:disable-next-line
// export = probot.server;
export = probot.server;
9 changes: 9 additions & 0 deletions src/server.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import {Probot} from "probot";
import {App} from "./App";
import {getAppConfig} from "./AppConfig";

const appConfig = getAppConfig();
const probot = new Probot(appConfig);
probot.load(App.handle);

probot.start();

0 comments on commit 9d3d0ac

Please sign in to comment.