This is an automated email from the ASF dual-hosted git repository.

potiuk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow-checks-action.git

commit b8b3df64d77768eb202194037bef4cb2977e6829
Author: Louis Brunner <[email protected]>
AuthorDate: Sat Feb 29 14:40:30 2020 +0000

    Create/Update check run
---
 .gitignore             |  2 +-
 README.md              | 20 +++++++++++++++++---
 __tests__/main.test.ts |  2 +-
 dist/index.js          |  2 +-
 src/main.ts            | 25 ++++++++++++++++++++++---
 5 files changed, 42 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index 18e337d..b1f7d2d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -96,4 +96,4 @@ Thumbs.db
 
 # Ignore built ts files
 __tests__/runner/*
-lib/**/*
\ No newline at end of file
+lib
diff --git a/README.md b/README.md
index 50aeb47..d3b92a1 100644
--- a/README.md
+++ b/README.md
@@ -1,7 +1,21 @@
 # GitHub Actions: `checks-action` 
![build-test](https://github.com/LouisBrunner/checks-action/workflows/build-test/badge.svg)
 
-TODO: description
+TODO: description & usage
 
-# Usage
+## Inputs
 
-TODO: usage
+### `who-to-greet`
+
+**Required** The name of the person to greet. Default `"World"`.
+
+## Outputs
+
+### `time`
+
+The time we greeted you.
+
+## Example usage
+
+uses: actions/hello-world-javascript-action@v1
+with:
+  who-to-greet: 'Mona the Octocat'
diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts
index dc55b7b..32cf034 100644
--- a/__tests__/main.test.ts
+++ b/__tests__/main.test.ts
@@ -5,7 +5,7 @@ import * as path from 'path'
 // shows how the runner will run a javascript action with env / stdout protocol
 test('test runs', () => {
   process.env['TOKEN'] = 'ABC'
-  const ip = path.join(__dirname, '..', 'dist', 'index.js')
+  const ip = path.join(__dirname, '..', 'lib', 'main.js')
   const options: cp.ExecSyncOptions = {
     env: process.env,
   }
diff --git a/dist/index.js b/dist/index.js
index b93d54d..24aa44e 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -1 +1 @@
-module.exports=function(e,t){"use strict";var r={};function 
__webpack_require__(t){if(r[t]){return r[t].exports}var 
n=r[t]={i:t,l:false,exports:{}};e[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return
 n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return 
__webpack_require__(429)}return 
startup()}({87:function(e){e.exports=require("os")},429:function(e,t,r){e.exports=function(e,t){"use
 strict";var r={};function __webpack_require__(t){if(r[t]){return r[t] [...]
\ No newline at end of file
+module.exports=function(e,t){"use strict";var r={};function 
__webpack_require__(t){if(r[t]){return r[t].exports}var 
n=r[t]={i:t,l:false,exports:{}};e[t].call(n.exports,n,n.exports,__webpack_require__);n.l=true;return
 n.exports}__webpack_require__.ab=__dirname+"/";function startup(){return 
__webpack_require__(429)}return 
startup()}({87:function(e){e.exports=require("os")},429:function(e,t,r){e.exports=function(e,t){"use
 strict";var r={};function __webpack_require__(t){if(r[t]){return r[t] [...]
\ No newline at end of file
diff --git a/src/main.ts b/src/main.ts
index 681610b..0208cac 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -9,14 +9,33 @@ async function run(): Promise<void> {
     core.debug(`Setting up OctoKit`)
     const octokit = new github.GitHub(token)
 
-    const checkRuns = octokit.checks.listForRef({
+    const ownership = {
       owner: github.context.repo.owner,
       repo: github.context.repo.repo,
+    }
+
+    const info = { // TODO: from argument
+    }
+
+    const { data } = await octokit.checks.listForRef({
+      ...ownership,
       ref: github.context.sha,
     })
-    core.info(JSON.stringify(checkRuns))
 
-    // TODO: finish
+    if (data.check_runs.length > 0) {
+      octokit.checks.update({
+        ...ownership,
+        check_run_id: data.check_runs[0].id,
+        ...info,
+      })
+    } else {
+      octokit.checks.create({
+        ...ownership,
+        head_sha: github.context.sha,
+        name: 'Check Run Test', // TODO: from argument
+        ...info,
+      })
+    }
   } catch (error) {
     core.setFailed(error.message)
   }

Reply via email to