ecma262-compare
ecma262-compare copied to clipboard
Post comment or status to ecma262 PR
Post URL to ecma262 PR, after updating PR data
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.
Requirement:
- post at most once per each PR
Mild requirement:
- do not post until gh-pages get deployed
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:
- Create
pr-comments.json
file with{ "posted": [], "new": [] }
content, inpr-comments
branch - When updating PR data:
- Let
comments
be the body ofpr-comments.json
- Let
prs
be the list of PR numbers that has been updated - Remove items from
prs
wherecomments.posted
also contains - Append
prs
tocomments.new
- Write
comments
topr-comments.json
- Commit and push to
pr-comments
branch
- Let
- When
gh-pages
gets deployed:- Let
comments
be the body ofpr-comments.json
- For each PR number
prnum
incomments.new
:- Post a comment to ecma262 PR
prnum
, with URL for the diff
- Post a comment to ecma262 PR
- Append
comments.new
tocomments.posted
- Let
comments.new
to[]
- Write
comments
topr-comments.json
- Commit and push to
pr-comments
branch
- Let
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
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.
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~~
I got "Resource not accessible by integration" when posting comments to other repository. looks like it needs some kind of token
Apparently, PAT for any user works.
listening to deployment doesn't work, even for manual push to gh-pages. I'll try just post comment immediately
Currently posting to https://github.com/arai-a/workflow-test/pull/2