Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: get input from @actions/core instead of env #11

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"test:ui": "yarn lint && vitest --coverage --ui"
},
"dependencies": {
"@actions/core": "^1.9.0",
tony19 marked this conversation as resolved.
Show resolved Hide resolved
"@octokit/rest": "^18.3.0",
"@types/node": "^14.14.31",
"@types/shelljs": "^0.8.8",
Expand Down
28 changes: 12 additions & 16 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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`)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this assertion mean that we can no longer test the whole logic in our local environments?
If so, how we can test its behavior before release?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I don't recall. This PR is so old, I've completely forgotten the context of this code, but I think this came from example code somewhere. I'll have to dig to find out the reason for it.


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)
Expand Down