Skip to content

Commit 332bd86

Browse files
gr2mbcoe
andauthoredDec 15, 2020
feat: initial version (#1)
Co-authored-by: bcoe <[email protected]>
1 parent f28112f commit 332bd86

12 files changed

+3047
-3
lines changed
 

Diff for: ‎.github/dependabot.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
version: 2
2+
updates:
3+
# create PRs for out-of-range updates
4+
- package-ecosystem: "npm"
5+
directory: "/"
6+
schedule:
7+
interval: "daily"
8+
versioning-strategy: "increase"

Diff for: ‎.github/workflows/deploy.yml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
name: Deploy
2+
on:
3+
push:
4+
branches:
5+
- main
6+
workflow_dispatch: {}
7+
8+
jobs:
9+
deploy:
10+
name: deploy-gcf
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
- name: Set up Cloud SDK
15+
uses: google-github-actions/setup-gcloud@master
16+
with:
17+
project_id: ${{ secrets.PROJECT_ID }}
18+
service_account_key: ${{ secrets.SERVICE_ACCOUNT_KEY }}
19+
export_default_credentials: true
20+
- name: Deploy to GCF
21+
run: |
22+
gcloud functions deploy example-google-cloud-function \
23+
--runtime nodejs12 \
24+
--allow-unauthenticated \
25+
--trigger-http \
26+
--entry-point probotApp \
27+
--set-env-vars APP_ID="${{secrets.APP_ID}}",PRIVATE_KEY="${{secrets.PRIVATE_KEY}}",WEBHOOK_SECRET="${{secrets.WEBHOOK_SECRET}}"

Diff for: ‎.github/workflows/release.yml

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

Diff for: ‎.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@v1
16+
- run: npm ci
17+
- run: npm test

Diff for: ‎.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.env
2+
node_modules

Diff for: ‎README.md

+21-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,27 @@
1-
# 🚧 Work in progress, see [#1](https://github.com/probot/example-google-cloud-function/pull/1)
2-
31
# Probot & Google Cloud Functions example
42

53
This repository is an example of how to deploy the "Hello, World" of probot apps to [Google Cloud Functions (GCF)](https://cloud.google.com/functions).
64

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+
## Deployment
22+
23+
The app is continuously deployed to Google Cloud using the [`setup-gcloud` GitHub Action](https://github.com/google-github-actions/setup-gcloud). See [`.github/workflows/deploy.yml`](.github/workflows/deploy.yml) for the deployment workflow.
24+
725
## License
826

9-
[ISC](LICENSE)
27+
[ISC](LICENSE)

Diff for: ‎app.js

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @param { {app: 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+
};

Diff for: ‎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

Diff for: ‎function.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const { createNodeMiddleware, createProbot } = require("probot");
2+
const app = require("./app");
3+
4+
exports.probotApp = createNodeMiddleware(app, { probot: createProbot() });

0 commit comments

Comments
 (0)
Please sign in to comment.