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

Action to auto-comment on pull requests with a link to the artifact #5539

Closed
wants to merge 2 commits into from
Closed

Action to auto-comment on pull requests with a link to the artifact #5539

wants to merge 2 commits into from

Conversation

oprypin
Copy link

@oprypin oprypin commented Feb 7, 2021

What is it?

  • Bugfix (user facing)
  • Feature (user facing)
  • Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

The issue

I first noticed that NewPipe has this issue via this comment (because I was globally searching GitHub for mentions of "https://nightly.link/", which is my project):

Github Actions doesn't allow guest users to download artifacts, which is pretty stupid. @Stypox and other PR authors, could you post nightly.link URLs so that users don't have to sign in just to access an APK? If not, then maybe @mhmdanas's bot could be used to download and upload the latest artifact to its comment somehow?

-- @opusforlife2 on Dec 30, 2020

(Also see the next few comments after that one)

So here I'm basically fulfilling both parts of this need: I'm adding a "bot" (really it's isolated entirely within GitHub Actions for this repo) that automatically posts such a link to the APK from the pull request and the link works for guest users.

Description of the changes in your PR

Whenever a CI build for a pull request succeeds, github-actions[bot] will comment (or edit the comment) with a link to directly download the artifact (i.e. the APK) from it. The bot's comment will tend to be near the start of the thread.

See an example of this in action here

The service https://nightly.link/ is used for the actual link because it allows downloads without logging in. It would be possible to instead make an equivalent link directly to GitHub, but users who happen to not be logged into GitHub will just get a 404 error.

Why this can't be done more simply:

  • Running the comment API directly from the pull request's action can't be done due to permission boundaries.
  • workflow_run is the intended place for commenting actions, but GitHub really just doesn't provide a way to find the originating pull request from this event, so we to have search for it through the SHA (and that basically takes up the top half of this). You can see what other hacks people have devised for this here and here
APK testing

Well yes, APK testing is exactly what this improves, so this section will become unnecessary:

On the website the APK can be found by going to the "Checks" tab below the title and then on "artifacts" on the right.

Due diligence

Note that I am not involved with NewPipe whatsoever, only popping in for this particular contribution, but I intend to always follow up on anything relating to it (you can always @ me or find me on IRC).

Whenever a CI build for a pull request succeeds, `github-actions[bot]` will comment (or edit the comment) with a link to directly download the artifact (i.e. the APK) from it. The bot's comment will tend to be near the start of the thread.

The service https://nightly.link/ is used for the actual link because it allows downloads without logging in. It is possible to make an equivalent link directly to GitHub, but users who happen to not be logged into GitHub will just get a 404 error.

Why this can't be done more simply:

* Running the comment API directly from the pull request's action can't be done due to permission boundaries.
* [workflow_run](https://docs.github.com/en/actions/reference/events-that-trigger-workflows#workflow_run) is the intended place for commenting actions, but GitHub really just doesn't provide a way to find the originating pull request from this event, so we have search for it through the SHA (and that basically takes up the top half of this). You can see what other hacks people have devised for this [here](https://github.com/nyurik/auto_pr_comments_from_forks) and [here](https://github.com/search?l=YAML&q=workflow_run+createComment&type=Code)
@triallax triallax added the meta Related to the project but not strictly to code label Feb 7, 2021
Copy link
Contributor

@triallax triallax left a comment

Choose a reason for hiding this comment

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

I tested this and it works great! We should probably remove the APK testing section yet again in another PR.

Edit: I just have a minor comment; see below.

.github/workflows/pr-comment.yml Outdated Show resolved Hide resolved
@XiangRongLin
Copy link
Collaborator

What are the stats/plans for uptime/relieability and co.

  • You are privatly running the instance, so what are the chances for this to still run in 1 month/year?
  • And since you are actively searching for projects (according to IRC) to use this on, what are your plans on scaling and paying for that scale. Would it stay free for us/open source and you contionue pay out of your own pocket?

@oprypin
Copy link
Author

oprypin commented Feb 10, 2021

This is running on a VPS that goes down pretty much only for restarts.

I am 100% sure that what's already here will stay free. And monetizing is not a goal.

The mention of "actively searching for projects" and "scale" is a bit overstated. The traffic is tiny now and I'm pretty sure that even for a 1000x increase I won't need to do anything. If it somehow gets crazy popular, sure, bring on the challenge, I'll tackle it. The good thing is that it's very very easy to shard the traffic.

Keeping this running long term is a matter of personal pride. While I say that traffic is low, it has certainly passed the threshold where I could just shut it down in good conscience.

The costs to me are almost nothing. Yes, I'll just keep paying for the hosting indefinitely - easily more than 1 year.

Worst case, you can delete and/or swap out all the links, so I'm not sure what there is to worry.

@oprypin
Copy link
Author

oprypin commented Feb 10, 2021

On a separate note, as written at https://nightly.link/, someone would ideally "install the GitHub app" for the org.

@oprypin
Copy link
Author

oprypin commented Feb 14, 2021

Anything holding this up?

1 similar comment
@oprypin
Copy link
Author

oprypin commented Feb 19, 2021

Anything holding this up?

@triallax
Copy link
Contributor

Sorry for the late reply. There's just some internal discussion within the team regarding this PR right now.

@oprypin
Copy link
Author

oprypin commented Mar 10, 2021

Welp, whenever you're ready, you're welcome to continue from https://github.com/oprypin/nightly.link/tree/master/.github/workflows

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta Related to the project but not strictly to code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants