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

If commentId is zero, add rather than update #73

Closed
wants to merge 1 commit into from
Closed

If commentId is zero, add rather than update #73

wants to merge 1 commit into from

Conversation

solvaholic
Copy link

Hiyo! Thank you so much for this action @peter-evans 🙇

I'm using create-or-update-comment to address solvaholic/octodns-sync#41

Given how the commentId is checked now:

if (inputs.commentId) {

It seems necessary to write separate workflow steps gated on comment-id in the find-comment output, to avoid an error when comment-id is zero.

If that check were more like "if commentId is set and it's not zero" then I think users could write one workflow step that will add a comment when comment-id is zero and update a comment when it's non-zero.

I tested the change I've submitted here over in solvaholic/scaling-succotash#5

To me it looks great but idk about javascript actions. Two questions I have for you:

What do you think of running the update vs. add check this way?

What's the relationship between index.js and dist/index.js in this repository?

@solvaholic solvaholic marked this pull request as draft February 15, 2021 23:13
@solvaholic
Copy link
Author

I flipped this PR to draft because that did not work at all the way I thought it might.

I'll work on it some more and come back.

@solvaholic
Copy link
Author

Ok :whew: it was just a problem with my workflow file. solvaholic/scaling-succotash#6 includes a less alarming test.

@solvaholic solvaholic marked this pull request as ready for review February 15, 2021 23:53
@peter-evans
Copy link
Owner

peter-evans commented Feb 16, 2021

@solvaholic When the find-comment action doesn't find a comment it returns an empty string, not zero. So I think the workflow you created should work without your changes to this action. Perhaps the example in this repository's readme was confusing because it looks like 0 is being returned?

@solvaholic
Copy link
Author

Ha! I didn't even think to try it. Sure enough, works no problem.

solvaholic/scaling-succotash#7

The example code appeared to reinforce my misunderstanding. I had initially misunderstood when this in the find-comment readme would matter:

Tip: Empty strings evaluate to zero in GitHub Actions expressions. e.g. If comment-id is an empty string steps.fc.outputs.comment-id == 0 evaluates to true.

Next time maybe I'll remember to try it out 😬

Thanks again 🙇

@solvaholic solvaholic closed this Feb 16, 2021
@solvaholic solvaholic deleted the solvaholic-patch-1 branch February 16, 2021 00:14
@peter-evans
Copy link
Owner

No worries. Sorry for misleading you. I think I need to improve the readme to make it more clear that this kind of 2-step workflow works.

@peter-evans
Copy link
Owner

I updated the readme to include a clearer example.

What's the relationship between index.js and dist/index.js in this repository?

For future reference, dist/index.js is automatically generated and should not be edited manually. Edit index.js and then run npm run package to generate the dist output. It compiles the project into a single Javascript file using ncc.

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.

2 participants