-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"env": { | ||
"commonjs": true, | ||
"es6": true, | ||
"node": true, | ||
"jasmine": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parserOptions": { | ||
"ecmaVersion": 2018 | ||
}, | ||
"rules": { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
name: Linting and Unit Tests | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- master | ||
- 'releases/*' | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v1 | ||
- run: npm install | ||
- run: npm run lint | ||
- run: npm test |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
# Dependency directory | ||
!node_modules | ||
|
||
# Rest pulled from https://github.com/github/gitignore/blob/master/Node.gitignore | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
bower_components | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directories | ||
jspm_packages/ | ||
|
||
# TypeScript v1 declaration files | ||
typings/ | ||
|
||
# TypeScript cache | ||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional eslint cache | ||
.eslintcache | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
*.tgz | ||
|
||
# Yarn Integrity file | ||
.yarn-integrity | ||
|
||
# dotenv environment variables file | ||
.env | ||
.env.test | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
.cache | ||
|
||
# next.js build output | ||
.next | ||
|
||
# nuxt.js build output | ||
.nuxt | ||
|
||
# vuepress build output | ||
.vuepress/dist | ||
|
||
# Serverless directories | ||
.serverless/ | ||
|
||
# FuseBox cache | ||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
.dynamodb/ | ||
|
||
# OS metadata | ||
.DS_Store | ||
Thumbs.db | ||
|
||
# Ignore built ts files | ||
__tests__/runner/* | ||
lib/**/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 GitHub Actions | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
![Linting and Unit Tests](https://github.com/leopic/gh-action-open-pr-slack-parser/workflows/Linting%20and%20Unit%20Tests/badge.svg?branch=master) | ||
|
||
# GitHub Open PR list Slack Block Parser | ||
A GitHub action, meant to be run on a schedule, to list all open pull requests on a GitHub repository. | ||
|
||
## Usage | ||
```yaml | ||
name: Verify All Open Pull Requests | ||
|
||
on: | ||
schedule: | ||
- cron: "0 9 * 1-5 *" | ||
|
||
jobs: | ||
run: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Get PR list | ||
uses: leopic/gh-action-open-pr-notifier@v1.0.0 | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
slackbot-token: YOUR_SLACKBOT_TOKEN | ||
slack-conversation-id: YOUR_CHANNEL_ID | ||
|
||
``` | ||
|
||
## Output example | ||
The output is similar to: | ||
![Usage example when integrated into Slack](https://cldup.com/_1kSIuUbXi.png) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: 'Open Pull Requests Notifier' | ||
description: 'Posts a message on slack with the list of open pull requests' | ||
inputs: | ||
github-token: | ||
required: true | ||
description: 'Needed to query pull requests' | ||
slackbot-token: | ||
required: true | ||
description: 'Needed to authenticate to Slacks API' | ||
slack-conversation-id: | ||
required: true | ||
description: 'Channel or group that the message will be delivered to' | ||
runs: | ||
using: 'node12' | ||
main: 'index.js' | ||
branding: | ||
icon: 'calendar' | ||
color: 'red' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
'use strict'; | ||
|
||
const GitHubCore = require('@actions/core'); | ||
const {context: GitHubContext, GitHub: GitHubClient} = require('@actions/github'); | ||
const {WebClient: SlackWebClient} = require('@slack/web-api'); | ||
|
||
const getMessage = require('./src/get-message'); | ||
const postMessage = require('./src/post-message'); | ||
const prefixError = require('./src/prefix-vendor-error-message'); | ||
|
||
module.exports.run = async () => { | ||
let message; | ||
|
||
try { | ||
const gitHubToken = GitHubCore.getInput('github-token') || process.env.GITHUB_TOKEN; | ||
const Octokit = new GitHubClient(gitHubToken); | ||
const {owner, repo} = GitHubContext.repo; | ||
message = await getMessage({Octokit, owner, repo}); | ||
|
||
GitHubCore.info('Message built'); | ||
} catch (error) { | ||
GitHubCore.setFailed(prefixError(error, 'GitHub')); | ||
return; | ||
} | ||
|
||
try { | ||
const slackToken = GitHubCore.getInput('slackbot-token') || process.env.SLACK_TOKEN; | ||
const Slack = new SlackWebClient(slackToken); | ||
const slackConversationId = GitHubCore.getInput('slack-conversation-id') || process.env.SLACK_CONVERSATION_ID; | ||
await postMessage({Slack, channel: slackConversationId, blocks: message}); | ||
|
||
GitHubCore.info('Message posted'); | ||
} catch (error) { | ||
GitHubCore.setFailed(prefixError(error, 'Slack')); | ||
} | ||
}; | ||
|
||
if (!process.argv.join('').includes('jasmine')) { | ||
module.exports.run(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.