From e11e96595180b7126a27c3cdc9c83aa0de9c25a9 Mon Sep 17 00:00:00 2001 From: Jiasheng Zhang Date: Fri, 28 May 2021 17:18:58 +0800 Subject: [PATCH] create status check * route change * create status check --- .github/actions/create_status_check/index.js | 34 ++++++++++++++++++++ .github/workflows/reply_action.yml | 6 ++++ 2 files changed, 40 insertions(+) create mode 100644 .github/actions/create_status_check/index.js diff --git a/.github/actions/create_status_check/index.js b/.github/actions/create_status_check/index.js new file mode 100644 index 000000000..41495c017 --- /dev/null +++ b/.github/actions/create_status_check/index.js @@ -0,0 +1,34 @@ +const core = require("@actions/core"); +const github = require("@actions/github"); + +async function run() { + try { + const [ + gitHubRepoOwner, + gitHubRepoName + ] = process.env.GITHUB_REPOSITORY.split("/"); + const gitHubSha = process.env.GITHUB_SHA; + const gitHubToken = core.getInput("github-token"); + + const octokit = new github.GitHub(gitHubToken); + + octokit.checks.create({ + owner: gitHubRepoOwner, + repo: gitHubRepoName, + name: "Check Created by API", + head_sha: gitHubSha, + status: "completed", + conclusion: "success", + output: { + title: "Check Created by API", + summary: `# All good ![step 1](https://www.imore.com/sites/imore.com/files/styles/w1600h900crop/public/field/image/2019/07/pokemonswordshieldstartertrio.jpg "Step 1")` + } + }); + + core.setOutput("time", new Date().toTimeString()); + } catch (error) { + core.setFailed(error.message); + } +} + +run(); diff --git a/.github/workflows/reply_action.yml b/.github/workflows/reply_action.yml index eae46c6b5..b69041c77 100644 --- a/.github/workflows/reply_action.yml +++ b/.github/workflows/reply_action.yml @@ -8,6 +8,12 @@ jobs: check_comments: runs-on: ubuntu-latest steps: + - name: Create Status Check + uses: ./.github/actions/create_status_check + with: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - name: Get the output time + run: echo "The time was ${{ steps.hello.outputs.time }}" - name: Pull Request Comment Trigger uses: Khan/pull-request-comment-trigger@1.0.0 id: check