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

add custom owner and repo inputs #78

Merged
merged 4 commits into from
Apr 24, 2023
Merged

add custom owner and repo inputs #78

merged 4 commits into from
Apr 24, 2023

Conversation

ReenigneArcher
Copy link
Contributor

This PR adds the ability to specify the repo owner and/or repo name in order to create a comment in another repo.

@ReenigneArcher
Copy link
Contributor Author

ReenigneArcher commented Mar 21, 2023

Please double check my work. I don't often work GitHub actions in this language.

I originally missed some things as I only changed the lib/config.js. I've since updated the src/config.ts and dist/index.js. I'm not familiar with your build mechanism but I'm guessing lib and dist are compiled somehow, which I did not do, only changed manually.

I have confirmed that this does allow commenting on a PR in another repo, so hopefully you can get this merged. I'm happy to clean up any code, but I have turned off "allow edits by maintainers" as I will be using this branch in my workflows.

@mshick
Copy link
Owner

mshick commented Apr 22, 2023

@ReenigneArcher That looks pretty good to me. It would probably be good to add a quick unit test for this. You'd need to make repoFullName re-assignable, and then in the new test do something like the following:

const repoOwner = 'my-owner';
const repoName = 'my-repo'
inputs['repo-owner'] = repoOwner
inputs['repo-name'] = repoName
repoFullName = `${repoOwner}/${repoName}`

await expect(run()).resolves.not.toThrow()
expect(core.setOutput).toHaveBeenCalledWith('comment-created', 'true')
expect(core.setOutput).toHaveBeenCalledWith('comment-id', postIssueCommentsResponse.id)

Since you said you're not as familiar with GitHub Actions I can merge and add for you after. Just let me know.

@ReenigneArcher
Copy link
Contributor Author

@mshick I added the test (hopefully correctly). Please let me know if something isn't right or should be changed before merging. I'm familiar with GitHub actions, but this is my first time playing with typescript. I've used Javascript a bit, but have not done any unit testing there yet.

Copy link
Owner

@mshick mshick left a comment

Choose a reason for hiding this comment

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

Great work adding the test. A few more suggestions. Like I mention, be sure to get the latest changes from main for the comments to make sense.

__tests__/add-pr-comment.test.ts Show resolved Hide resolved
__tests__/add-pr-comment.test.ts Show resolved Hide resolved
src/config.ts Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
action.yml Outdated Show resolved Hide resolved
@ReenigneArcher
Copy link
Contributor Author

Did I miss something in the test? I'm not seeing the reason for the failure.

@mshick
Copy link
Owner

mshick commented Apr 23, 2023

@ReenigneArcher No, it's the perms... I haven't figured out how to get write perms for public forks. I'll test locally and merge if everything looks good.

@mshick
Copy link
Owner

mshick commented Apr 24, 2023

Ah, so, a few things going on. Some are just general updates to the tests. The main reason yours is failing is that you're not setting a message in your test, adding this line inputs.message = simpleMessage will solve it. I need to add better logging for test cases so these things are easier to debug.

I'm going to go ahead and merge your PR and I'll make the other updates myself. Thanks for the contribution! I'll have a new version out soon.

@mshick mshick merged commit 1605572 into mshick:main Apr 24, 2023
@mshick
Copy link
Owner

mshick commented Apr 24, 2023

@all-contributors please add @ReenigneArcher for code

@allcontributors
Copy link
Contributor

@mshick

I've put up a pull request to add @ReenigneArcher! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

comment on a PR in another repo
2 participants