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

Post comment or status to ecma262 PR #16

Open
arai-a opened this issue Feb 14, 2020 · 9 comments
Open

Post comment or status to ecma262 PR #16

arai-a opened this issue Feb 14, 2020 · 9 comments

Comments

@arai-a
Copy link
Owner

arai-a commented Feb 14, 2020

Post URL to ecma262 PR, after updating PR data

@arai-a
Copy link
Owner Author

arai-a commented Mar 1, 2020

There's issue about the delay,
gh-pages doesn't update immediately after the push (takes ~10 minutes).
So, posting the URL in the same job for updating PR history might be misleading.

@arai-a
Copy link
Owner Author

arai-a commented Mar 1, 2020

Requirement:

  • post at most once per each PR

Mild requirement:

  • do not post until gh-pages get deployed

@arai-a
Copy link
Owner Author

arai-a commented Mar 1, 2020

do not post until gh-pages get deployed

https://help.github.com/en/actions/reference/events-that-trigger-workflows#deployment-event-deployment

post at most once per each PR

Storing a JSON file that tracks it can solve.
(It's better avoid accessing PR comments for it, because it consumes the access limit)
but it should be stored in other branch than gh-pages, say pr-comments branch.
(otherwise updating the JSON file triggers another deployment)

possible flow:

  1. Create pr-comments.json file with { "posted": [], "new": [] } content, in pr-comments branch
  2. When updating PR data:
    1. Let comments be the body of pr-comments.json
    2. Let prs be the list of PR numbers that has been updated
    3. Remove items from prs where comments.posted also contains
    4. Append prs to comments.new
    5. Write comments to pr-comments.json
    6. Commit and push to pr-comments branch
  3. When gh-pages gets deployed:
    1. Let comments be the body of pr-comments.json
    2. For each PR number prnum in comments.new:
      1. Post a comment to ecma262 PR prnum, with URL for the diff
    3. Append comments.new to comments.posted
    4. Let comments.new to []
    5. Write comments to pr-comments.json
    6. Commit and push to pr-comments branch

Here, check for comments.new should be done without cloning the repository, to avoid unnecessary traffic.
and if comments.new isn't empty, clone it and do the remaining

@arai-a
Copy link
Owner Author

arai-a commented Mar 1, 2020

https://developer.github.com/v3/repos/contents/#create-or-update-a-file

this could be used to avoid clone even if comments.new isn't empty.

@arai-a
Copy link
Owner Author

arai-a commented Mar 1, 2020

https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#about-the-github_token-secret

The token's permissions are limited to the repository that contains your workflow. For more information

https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token#permissions-for-the-github_token

Creating PR comment on ecma262 cannot be done with secrets.GITHUB_TOKEN.
so we need encrypted PAT for ecma262 repository.

I guess adding a comment doesn't need PAT or any extra permission

@arai-a
Copy link
Owner Author

arai-a commented Mar 2, 2020

I got "Resource not accessible by integration" when posting comments to other repository.
looks like it needs some kind of token

@arai-a
Copy link
Owner Author

arai-a commented Mar 2, 2020

Apparently, PAT for any user works.

@arai-a
Copy link
Owner Author

arai-a commented Mar 2, 2020

listening to deployment doesn't work, even for manual push to gh-pages.
I'll try just post comment immediately

@arai-a
Copy link
Owner Author

arai-a commented Mar 7, 2020

Currently posting to arai-a/workflow-test#2

@arai-a arai-a changed the title Post comment to ecma262 PR Post comment or status to ecma262 PR Mar 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant