diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index ca0cea3..5ea3b15 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -1,4 +1,4 @@ -name: Test PRa +name: Test PR on: pull_request: types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled] diff --git a/.github/workflows/workflow_run.yml b/.github/workflows/workflow_run.yml new file mode 100644 index 0000000..7a21c61 --- /dev/null +++ b/.github/workflows/workflow_run.yml @@ -0,0 +1,30 @@ +name: Test + +on: + workflow_run: + workflows: + - setup + types: + - completed + +jobs: + test-job: + name: Test Step + runs-on: ubuntu-latest + steps: + - run: env + - uses: ./ + with: + prompt: | + 1. open youtube + os: windows + prerun: | + cd $env:TEMP + npm init -y + npm install dashcam-chrome + Start-Process "C:/Program Files/Google/Chrome/Application/chrome.exe" -ArgumentList "--start-maximized","--load-extension=$(pwd)/node_modules/dashcam-chrome/build" + exit + key: ${{ secrets.DASHCAM_WORKSPACE_API }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + FORCE_COLOR: "3" diff --git a/.github/workflows/workflow_setup.yml b/.github/workflows/workflow_setup.yml new file mode 100644 index 0000000..4d5c48b --- /dev/null +++ b/.github/workflows/workflow_setup.yml @@ -0,0 +1,12 @@ +name: setup + +on: + - pull_request + - push + +jobs: + preflight-job: + name: Preflight Step + runs-on: ubuntu-latest + steps: + - run: env diff --git a/dist/index.js b/dist/index.js index 835dcc6..98533a2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -866,7 +866,7 @@ formatters.O = function (v) { /***/ }), -/***/ 8818: +/***/ 7404: /***/ ((module) => { "use strict"; @@ -1058,7 +1058,7 @@ function plural(ms, msAbs, n, name) { const os = __nccwpck_require__(2037); const tty = __nccwpck_require__(6224); -const hasFlag = __nccwpck_require__(8818); +const hasFlag = __nccwpck_require__(7404); const {env} = process; @@ -8414,7 +8414,7 @@ function removeHook(state, name, method) { /***/ }), -/***/ 3040: +/***/ 8818: /***/ ((module, __unused_webpack_exports, __nccwpck_require__) => { "use strict"; @@ -34824,6 +34824,7 @@ function wrappy (fn, cb) { const core = __nccwpck_require__(2186); const github = __nccwpck_require__(5438); +const chalk = __nccwpck_require__(8818); class Config { constructor() { @@ -34847,6 +34848,40 @@ class Config { prTitle: createPR ? core.getInput("pr-title") : "", prTestFilename: createPR ? core.getInput("pr-test-filename") : "", }; + + let branchInfo = () => { + + + let sha = github.context.sha; + let ref = github.context.ref; + let context = ''; + + if (github.context.event_name == "workflow_run") { + context = 'workflow_run'; + sha = github.context.event.workflow_run.pull_requests[0].head.sha; + ref = github.context.event.workflow_run.pull_requests[0].head.ref; + } else if (github.context.payload?.pull_request) { + context = 'pull_request'; + sha = github.context.payload.pull_request.head.sha; + ref = github.context.payload.pull_request.head.ref; + } else { + context = 'default' + sha = github.context.sha; + ref = github.context.ref; + } + + let res = {sha, ref, context}; + + console.log(""); + console.log(chalk.green("Context")); + console.log(chalk.yellow("method:"), context); + console.log(chalk.yellow("ref:"), ref); + console.log(chalk.yellow("sha:"), sha); + + return res; + } + + let {sha, ref, context} = branchInfo(); // the values of github.context.repo.owner and github.context.repo.repo are taken from // the environment variable GITHUB_REPOSITORY specified in "owner/repo" format and @@ -34857,9 +34892,8 @@ class Config { issueNumber: github.context.issue.number, branch: github.context.ref, token: github.context.token || github.token, - sha: github.context.payload?.pull_request?.head.sha || github.context.sha, - head_ref: github.context.head_ref, - ref: github.context.ref, + sha, + ref, workflow: github.context.workflow, run_id: github.context.runId }; @@ -41162,7 +41196,7 @@ var __webpack_exports__ = {}; const core = __nccwpck_require__(2186); const config = __nccwpck_require__(4570); const axios = __nccwpck_require__(8757); -const chalk = __nccwpck_require__(3040); +const chalk = __nccwpck_require__(8818); const { getOctokit } = __nccwpck_require__(5438); (__nccwpck_require__(2437).config)(); @@ -41228,6 +41262,7 @@ axios.interceptors.response.use( let prTitle = config.input.prTitle; let prTestFilename = config.input.prTestFilename; + console.log(chalk.green("Version")); console.log(`testdriver@${pgkVersion}`); console.log(`testdriver-action@${testdriverBranch}`); @@ -41447,7 +41482,7 @@ axios.interceptors.response.use( replayUrl: extractedFromMarkdown, instructions: prompt, repo: repo, - branch: config.githubContext.head_ref || config.githubContext.ref, + branch: config.githubContext.ref, commit: config.githubContext.sha, platform: os, success: isPassed, diff --git a/src/config.js b/src/config.js index ea461d1..88cafc5 100644 --- a/src/config.js +++ b/src/config.js @@ -1,5 +1,6 @@ const core = require("@actions/core"); const github = require("@actions/github"); +const chalk = require("chalk"); class Config { constructor() { @@ -23,6 +24,40 @@ class Config { prTitle: createPR ? core.getInput("pr-title") : "", prTestFilename: createPR ? core.getInput("pr-test-filename") : "", }; + + let branchInfo = () => { + + + let sha = github.context.sha; + let ref = github.context.ref; + let context = ''; + + if (github.context.event_name == "workflow_run") { + context = 'workflow_run'; + sha = github.context.event.workflow_run.pull_requests[0].head.sha; + ref = github.context.event.workflow_run.pull_requests[0].head.ref; + } else if (github.context.payload?.pull_request) { + context = 'pull_request'; + sha = github.context.payload.pull_request.head.sha; + ref = github.context.payload.pull_request.head.ref; + } else { + context = 'default' + sha = github.context.sha; + ref = github.context.ref; + } + + let res = {sha, ref, context}; + + console.log(""); + console.log(chalk.green("Context")); + console.log(chalk.yellow("method:"), context); + console.log(chalk.yellow("ref:"), ref); + console.log(chalk.yellow("sha:"), sha); + + return res; + } + + let {sha, ref, context} = branchInfo(); // the values of github.context.repo.owner and github.context.repo.repo are taken from // the environment variable GITHUB_REPOSITORY specified in "owner/repo" format and @@ -33,9 +68,8 @@ class Config { issueNumber: github.context.issue.number, branch: github.context.ref, token: github.context.token || github.token, - sha: github.context.payload?.pull_request?.head.sha || github.context.sha, - head_ref: github.context.head_ref, - ref: github.context.ref, + sha, + ref, workflow: github.context.workflow, run_id: github.context.runId }; diff --git a/src/index.js b/src/index.js index be3df1a..c648251 100644 --- a/src/index.js +++ b/src/index.js @@ -67,6 +67,7 @@ axios.interceptors.response.use( let prTitle = config.input.prTitle; let prTestFilename = config.input.prTestFilename; + console.log(chalk.green("Version")); console.log(`testdriver@${pgkVersion}`); console.log(`testdriver-action@${testdriverBranch}`); @@ -286,7 +287,7 @@ axios.interceptors.response.use( replayUrl: extractedFromMarkdown, instructions: prompt, repo: repo, - branch: config.githubContext.head_ref || config.githubContext.ref, + branch: config.githubContext.ref, commit: config.githubContext.sha, platform: os, success: isPassed,