Giter Club home page Giter Club logo

msg-summary-git-pull-requests-to-slack's Introduction

Purpose

This script is used to retrieve open pull requests for an organisation from the github graphql api and post a summary of the information about them to a slack channel.

Pre-requisites

  1. You will need a Personal Access Token from github
  2. You will need to create an application for Slack, and get the OAuth token for the application (with at least the chat:write:user scope)

Installation and usage

  1. Install node.js - https://nodejs.org/
  2. Use the node package manager (npm) to install the following packages:
  • npm install -g typescript
  • npm install @types/node
  • npm install @octokit/graphql
  • npm install moment
  • npm install moment-business-days
  • npm install @slack/web-api
  • npm install cisco-vpn
  • npm install ps-node
  1. Clone this repository to a directory of your choosing
  2. Initialise typescript in the directory you cloned the repo into
  • npm run tsc -- --init
  1. Create /src/config.ts and populate it as described below
  2. Create a personal access token as per https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line

Configuration

The content of the /src/config.ts should be as follows:

export const gitUrl: string = 'https://www.github.com/api'; // Enterprise users should replace this with their own URL
export const pass: string = 'QUSV065T5P88NTQ9XHMA6CA184CPX2EUM4OR0BYF'; // Github personal access token - example is not a real token - select repo, gist and users scopes
export const oauthToken: string = 'xoxp-28841330430-452313974416-300102328521-k8eniubfprdxjp3m4fv65z7j1oc57lfy'; // Slack application oauth token - will start with xoxp- example is not a real token
export const channel: string = 'OJQY8BFJJ'; // Slack channel ID - example is not a real channel id
export const organisation: string = 'MyOrganisation'; // Github organisation name 
export const vpnhost: string = 'remote.organisation.com';
export const vpnuser: string = 'your username';
export const vpnpass: string = 'your password'
export const vpnexe: string = 'C:\\Program Files (x86)\\Cisco\\Cisco AnyConnect Secure Mobility Client\\vpncli.exe';

Transpile

  1. Run tsc (this transpiles the TypeScript code (.ts) into JavaScript (.js) )
  2. Confirm that /build/config.js and /build/g2s.js have been created

Execute

  1. Run node ./build/g2s.js
  2. Confirm that a message was pushed to Slack

Scheduling

On Windows 10 I used the built in Task Scheduler application, that would trigger the node application and pass the path to the javascript file as an argument.

  1. In the task schedule, I added an action that called the program: C:\nodejs\node.exe
  2. I added the argument with the full path to the javascript file C:\Users\nick.myers\Documents\GitHub\g2s\build\g2s.js

Example output (as a slack message)

repository-1 has 2 open pull request(s):
• 2 days old: Feature/APP-1234 Makes changes - https://www.github.com/organisation/repository-1/pull/25
• 6 days old: Feature/APP-1236 Makes changes to the secondary api… - https://www.github.com/organisation/repository-1/pull/24

repository-2 has 1 open pull request(s):
• 11 days old: APP-1235 added tags - https://www.github.com/organisation/repository-2/pull/60

repository-3 has 2 open pull request(s):
• 6 days old: APP-1236: Updates node.js version to the latest version of 10 supported b… - https://www.github.com/organisation/repository-3/pull/75
• 11 days old: APP-1237 Added tags to the change set, this will add tags to all objec… - https://www.github.com/organisation/repository-3/pull/72

msg-summary-git-pull-requests-to-slack's People

Contributors

nick-myers avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.