diff --git a/action.yml b/action.yml index 29369d9..0eb7870 100644 --- a/action.yml +++ b/action.yml @@ -43,17 +43,6 @@ runs: run: ${{ github.action_path }}/scripts/checkout.sh shell: bash - name: Run Ryu-Cho - env: - ACCESS_TOKEN: ${{ inputs.access-token }} - USER_NAME: ${{ inputs.username }} - EMAIL: ${{ inputs.email }} - UPSTREAM_REPO: ${{ inputs.upstream-repo }} - UPSTREAM_REPO_BRANCH: ${{ inputs.upstream-repo-branch }} - HEAD_REPO: ${{ inputs.head-repo }} - HEAD_REPO_BRANCH: ${{ inputs.head-repo-branch }} - TRACK_FROM: ${{ inputs.track-from }} - PATH_STARTS_WITH: ${{ inputs.path-starts-with }} - WORKFLOW_NAME: ${{ inputs.workflow-name }} run: | cd ryu-cho yarn install diff --git a/package.json b/package.json index e8884b3..3bccaef 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "test:ui": "yarn lint && vitest --coverage --ui" }, "dependencies": { + "@actions/core": "^1.9.0", "@octokit/rest": "^18.3.0", "@types/node": "^14.14.31", "@types/shelljs": "^0.8.8", diff --git a/src/index.ts b/src/index.ts index a9df293..83e8ec1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,25 +1,21 @@ import { assert } from './utils' import { createConfig } from './config' import { RyuCho } from './ryu-cho' +import core from '@actions/core' -assert(!!process.env.ACCESS_TOKEN, '`accessToken` is required.') -assert(!!process.env.USER_NAME, '`userName` is required.') -assert(!!process.env.EMAIL, '`email` is required.') -assert(!!process.env.UPSTREAM_REPO, '`upstreamRepo` is required.') -assert(!!process.env.HEAD_REPO, '`headRepo` is required.') -assert(!!process.env.TRACK_FROM, '`trackFrom` is required.') +assert(typeof core !== 'undefined', `core is undefined, which probably means you're not running in a GitHub Action`) const config = createConfig({ - accessToken: process.env.ACCESS_TOKEN!, - userName: process.env.USER_NAME!, - email: process.env.EMAIL!, - upstreamRepo: process.env.UPSTREAM_REPO!, - upstreamRepoBranch: process.env.UPSTREAM_REPO_BRANCH, - headRepo: process.env.HEAD_REPO!, - headRepoBranch: process.env.HEAD_REPO_BRANCH, - workflowName: process.env.WORKFLOW_NAME, - trackFrom: process.env.TRACK_FROM!, - pathStartsWith: process.env.PATH_STARTS_WITH + accessToken: core.getInput('access-token', { required: true }), + userName: core.getInput('username', { required: true }), + email: core.getInput('email', { required: true }), + upstreamRepo: core.getInput('upstream-repo', { required: true }), + upstreamRepoBranch: core.getInput('upstream-repo-branch', { required: true }), + headRepo: core.getInput('head-repo', { required: true }), + headRepoBranch: core.getInput('head-repo-branch'), + workflowName: core.getInput('workflow-name'), + trackFrom: core.getInput('track-from', { required: true }), + pathStartsWith: core.getInput('path-starts-with'), }) const ryuCho = new RyuCho(config) diff --git a/yarn.lock b/yarn.lock index 666252f..1fed00f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,6 +2,21 @@ # yarn lockfile v1 +"@actions/core@^1.9.0": + version "1.10.0" + resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f" + integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug== + dependencies: + "@actions/http-client" "^2.0.1" + uuid "^8.3.2" + +"@actions/http-client@^2.0.1": + version "2.0.1" + resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c" + integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw== + dependencies: + tunnel "^0.0.6" + "@esbuild/android-arm@0.15.13": version "0.15.13" resolved "https://registry.yarnpkg.com/@esbuild/android-arm/-/android-arm-0.15.13.tgz#ce11237a13ee76d5eae3908e47ba4ddd380af86a" @@ -684,6 +699,11 @@ ts-node@^9.1.1: source-map-support "^0.5.17" yn "3.1.1" +tunnel@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c" + integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg== + type-detect@^4.0.0, type-detect@^4.0.5: version "4.0.8" resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" @@ -699,6 +719,11 @@ universal-user-agent@^6.0.0: resolved "https://registry.yarnpkg.com/universal-user-agent/-/universal-user-agent-6.0.0.tgz#3381f8503b251c0d9cd21bc1de939ec9df5480ee" integrity sha512-isyNax3wXoKaulPDZWHQqbmIx1k2tb9fb3GGDBRxCscfYV2Ch7WxPArBsFEG8s/safwXTT7H4QGhaIkTp9447w== +uuid@^8.3.2: + version "8.3.2" + resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2" + integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg== + vite@^3.0.0: version "3.2.3" resolved "https://registry.yarnpkg.com/vite/-/vite-3.2.3.tgz#7a68d9ef73eff7ee6dc0718ad3507adfc86944a7"