Creating test code for Github

This commit is contained in:
Julien Lengrand-Lambert
2020-07-30 22:52:14 +02:00
parent 769a7011a9
commit 5b986a0916
10 changed files with 51 additions and 18 deletions

1
.gitignore vendored
View File

@@ -5,3 +5,4 @@ package-lock.json
yarn.lock
.firebase
*.log
.env

View File

@@ -1,4 +1,5 @@
https://github.com/actions-on-google/actions-builder-hello-world-nodejs
https://console.actions.google.com/u/0/project/github-project-321e8/settings/general
https://developers.google.com/assistant/actionssdk/gactions
https://github.com/octokit/core.js#readme
https://github.com/octokit/core.js#readme
https://actions-on-google.github.io/assistant-conversation-nodejs/3.0.0/index.html

View File

@@ -1 +1 @@
transitionToScene: Start
transitionToScene: GithubStart

View File

@@ -0,0 +1,19 @@
conditionalEvents:
- condition: scene.slots.status == "FINAL"
handler:
webhookHandler: create_github_repository
onEnter:
staticPrompt:
candidates:
- promptResponse:
firstSimple:
variants:
- speech: Seems like you want to create a repository. What name would you
like to use?
slots:
- commitBehavior:
writeSessionParam: project_name_slot
name: project_name_slot
required: true
type:
name: project_name

View File

@@ -0,0 +1 @@
{}

View File

@@ -0,0 +1 @@
freeText: {}

View File

@@ -1,4 +1,5 @@
handlers:
- name: start_scene_initial_prompt
- name: create_github_repository
inlineCloudFunction:
executeFunction: ActionsOnGoogleFulfillment

View File

@@ -1,19 +1,3 @@
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
const {conversation} = require('@assistant/conversation');
const functions = require('firebase-functions');
@@ -26,4 +10,12 @@ app.handle('start_scene_initial_prompt', (conv) => {
conv.add('Hello world from fulfillment');
});
app.handle('create_github_repository', (conv) => {
console.log('Start scene: create_github_repository');
conv.overwrite = false;
conv.scene.next.name = 'actions.scene.END_CONVERSATION';
conv.add('Hello world from ' + conv.scene.slots.project_name_slot.value);
console.log(conv.scene.slots.project_name_slot.value);
});
exports.ActionsOnGoogleFulfillment = functions.https.onRequest(app);

View File

@@ -13,6 +13,7 @@
},
"dependencies": {
"@assistant/conversation": "^3.0.0",
"@octokit/core": "^3.1.1",
"firebase-admin": "~8.12.1",
"firebase-functions": "^3.6.2"
},

View File

@@ -0,0 +1,16 @@
const { request } = require("@octokit/request");
const { Octokit } = require("@octokit/core");
const octokit = new Octokit({ auth: `test` });
const start = async function(){
const response = await octokit.request("GET /users/:username/repos", {
username: "jlengrand",
});
console.log(`${response.data.length} repos found.`);
console.log(`${response.data[0]}`);
}
start();