Skip to content

Commit d6486cb

Browse files
committed
feat: initial version
0 parents  commit d6486cb

File tree

12 files changed

+3167
-0
lines changed

12 files changed

+3167
-0
lines changed

.github/workflows/release.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- main
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v2
12+
- uses: actions/setup-node@v2
13+
with:
14+
node-version: 14
15+
- run: npx semantic-release
16+
env:
17+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/test.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
name: Test
2+
on:
3+
push:
4+
branches:
5+
- main
6+
pull_request:
7+
types: [opened, synchronize]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v2
15+
- uses: actions/setup-node@v2
16+
- run: npm ci
17+
- run: npm test

.gitignore

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# local configuration
2+
.env
3+
4+
# package directories
5+
node_modules

CODE_OF_CONDUCT.md

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Contributor Covenant Code of Conduct
2+
3+
## Our Pledge
4+
5+
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6+
7+
## Our Standards
8+
9+
Examples of behavior that contributes to creating a positive environment include:
10+
11+
- Using welcoming and inclusive language
12+
- Being respectful of differing viewpoints and experiences
13+
- Gracefully accepting constructive criticism
14+
- Focusing on what is best for the community
15+
- Showing empathy towards other community members
16+
17+
Examples of unacceptable behavior by participants include:
18+
19+
- The use of sexualized language or imagery and unwelcome sexual attention or advances
20+
- Trolling, insulting/derogatory comments, and personal or political attacks
21+
- Public or private harassment
22+
- Publishing others' private information, such as a physical or electronic address, without explicit permission
23+
- Other conduct which could reasonably be considered inappropriate in a professional setting
24+
25+
## Our Responsibilities
26+
27+
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28+
29+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30+
31+
## Scope
32+
33+
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34+
35+
## Enforcement
36+
37+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at [email protected]. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38+
39+
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40+
41+
## Attribution
42+
43+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44+
45+
[homepage]: http://contributor-covenant.org
46+
[version]: http://contributor-covenant.org/version/1/4/

LICENSE

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ISC License
2+
3+
Copyright (c) 2020 Probot Contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Probot & Netlify Functions example
2+
3+
This repository is an example of how to deploy the "Hello, World" of probot apps to [Netlify Functions](https://www.netlify.com/products/functions/).
4+
5+
## Local setup
6+
7+
Install dependencies
8+
9+
```
10+
npm install
11+
```
12+
13+
Start the server
14+
15+
```
16+
npm start
17+
```
18+
19+
Follow the instructions to register a new GitHub app.
20+
21+
## Run the netlify function locally
22+
23+
You need to run `npm start` at least once in order to register a new GitHub App for your local testing. It will create a `.env` file with your app's credentials once it's done.
24+
25+
Install the [Netlify Dev CLI](https://www.netlify.com/products/dev/)
26+
27+
```
28+
npm install --global netlify-cli
29+
```
30+
31+
Then start it the root folder of this repository
32+
33+
```
34+
netlify dev
35+
```
36+
37+
In a new terminal app, start [`smee-client`](https://github.com/probot/smee-client/#readme) in order to receive webhook event requests from GitHub
38+
39+
```
40+
npx smee --url [WEBHOOK_PROXY_URL] --target http://127.0.0.1:8888/.netlify/functions/webhooks
41+
```
42+
43+
Replace `WEBHOOK_PROXY_URL` with the value of `WEBHOOK_PROXY_URL` in your `.env` file.
44+
45+
## Deployment
46+
47+
_tbd_
48+
49+
## License
50+
51+
[ISC](LICENSE)

app.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param {import('probot').Probot} app
3+
*/
4+
module.exports = (app) => {
5+
app.log("Yay! The app was loaded!");
6+
7+
app.on("issues.opened", async (context) => {
8+
return context.octokit.issues.createComment(
9+
context.issue({ body: "Hello, World!" })
10+
);
11+
});
12+
};

app.yml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
default_events:
2+
- issues
3+
4+
default_permissions:
5+
issues: write
6+
metadata: read

netlify/functions/webhooks.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const { createProbot } = require("probot");
2+
const app = require("../../app");
3+
4+
const probot = createProbot();
5+
const loadingApp = probot.load(app);
6+
7+
/**
8+
* Netlify function to handle webhook event requests from GitHub
9+
*
10+
* @param {import("@netlify/functions").HandlerEvent} event
11+
* @param {import("@netlify/functions").HandlerContext} context
12+
*/
13+
exports.handler = async function (event, context) {
14+
try {
15+
await loadingApp;
16+
17+
// this could will be simpler once we ship `verifyAndParse()`
18+
// see https://github.com/octokit/webhooks.js/issues/379
19+
await probot.webhooks.verifyAndReceive({
20+
id:
21+
event.headers["X-GitHub-Delivery"] ||
22+
event.headers["x-github-delivery"],
23+
name: event.headers["X-GitHub-Event"] || event.headers["x-github-event"],
24+
signature:
25+
event.headers["X-Hub-Signature-256"] ||
26+
event.headers["x-hub-signature-256"],
27+
payload: JSON.parse(event.body),
28+
});
29+
30+
return {
31+
statusCode: 200,
32+
body: '{"ok":true}',
33+
};
34+
} catch (error) {
35+
app.log.error(error);
36+
37+
return {
38+
statusCode: error.status || 500,
39+
error: "ooops",
40+
};
41+
}
42+
};

0 commit comments

Comments
 (0)