nightly.link
nightly.link copied to clipboard
How to handle non-static names?
I'd like to set up a script to mirror one build every night from repo mamedev/mame.
The YML is at https://github.com/mamedev/mame/blob/master/.github/workflows/ci-windows.yml and it shows this particular line:
name: mame-windows-gcc-${{ github.sha }}
Since it doesn't have an actual static name like the Windows.zip example from your site, is there any way to tell nightly.link to just provide the link to whatever file is present?
Currently there's no way to achieve this. But you could link to the workflow page which would show a download link but would not be a direct download.
My initial impression:
- Yes it's actually a good idea to augment filenames like that, I haven't considered it
- No it's horribly out of scope for nightly.link
(I'll get back once I think more on this)
The main thing, though: What happens if there are more than 1 artifacts? What should people do if they start using the service like this and then realize they need more than 1 artifact?
And regarding this in particular:
I'd like to set up a script to mirror one build every night from repo mamedev/mame.
Why don't you just use GitHub's API directly then? Generally that kind of usage is discouraged with nightly.link (it's meant mainly for guest visitors)
I was curious if there was a way it's already doing this?
From the nightly.link website if I paste a workflow URL and click the "get links" button, the hash-named artifact downloads. However, I couldn't figure out how that is accomplished.
Though I'd also like to ask about your suggested workaround. How does one link to the last workflow run? At least being able to direct someone to that page the artifact link would be right there... but if you meant the workflow page it would be a list of runs, which is what I was hoping there was something better than that, since I feel it's non-obvious to the user that they have to open the latest job first.
@bbbradsmith
You can link to the latest run or a particular run without naming the artifact, then you'll get the list of files. But you can also link directly to a file, see next.
The hash cannot be figured out, it's based on a secret. But the hash is constant within 1 repository, so the name of the artifact download can be arbitrarily changed in the URL.
Hope this helps.
I don't understand how I can link to the latest run, which was what I was asking.
However, trying some permutations based on I was guessing you were suggesting, I accidentally discovered that if I use a URL of this form it will link directly to the archive download, which I think was what was requested in the first place?
https://nightly.link/[organization]/[repository]/workflows/[workflow]/[branch]
Correspond to a link from to the workflow file in the repository, for reference:
https://github.com/[organization]/[repository]/blob/[branch]/.github/workflows/[workflow].yml
However, I think also knowing how to link to the latest run would be useful, for the case of multiple artifacts.
The site's interface has "getting a link to the latest artifact" as its primary "user journey". So I am not sure what I can add to that
Also you mentioned that you were "guessing" something. Exactly something that is described near the top of the website, inside the section "Link to a repository's latest artifact". Also I am saying that it's not necessary to know this, you can just follow the form on the main page.
Okay, that's the question I'm asking. Which site's interface are you referring to. Where is the link. What is the "primary user journey"?
https://nightly.link/
Also you mentioned that you were "guessing" something. Exactly something that is described near the top of the website, inside the section "Link to a repository's latest artifact". Also I am saying that it's not necessary to know this, you can just follow the form on the main page.
I read every word on the page, there is no example that matches the form I just described. Under "Link to a repository's latest artifact" there is a link almost of the form I just described but it was not at all obvious to me that I could delete the artifact name from the end. Any slight variation (e.g. leaving on the /) results in an error instead of downloading anything, so it took many permutations of guessing to find that it worked.
I was trying permutations based on you saying "You can link to the latest run or a particular run without naming the artifact, then you'll get the list of files." but I didn't know what you meant, and the link I arrived at did not get a list of files either.
https://nightly.link/
I don't see an explanation of how to link to the most recent run. I only see explanations of how to link to specific runs. What am I missing?
Anyway, what I'm suggesting is that what I just described in my comment above might actually be the answer Firehawke was looking for? It was at least what I was looking for, and I interpreted their question to be the same.
I think one extra example in "Link to a repository's latest artifact" showing the URL form without the artifact name would clarify that this can be done and how to do it, which other users like me might benefit from.
(This tool is great, BTW. Thank you for making it.)
No I think the original question is how to get a direct link to an artifact that slightly changes its name every time.
mame-windows-gcc-aaaaaaa.zip mame-windows-gcc-bbbbbbb.zip
which there's still no way to get a direct link that would match both of the files
Simply omitting the artifact name can put you onto a webpage with the download link. But there's no way to get a direct download link that works dynamically
When I use this link: https://nightly.link/bbbradsmith/hatariB/workflows/win64/main
It correctly downloads hatarib-2023-08-08-015623--007e616.zip
like I was hoping, there seems to be no need to call out the artifact by name?
@bbbradsmith Ah that's true, it's a special case for when a workflow produces exactly 1 artifact
Ah I see, so for the original one, we get such a page: https://nightly.link/mamedev/mame/workflows/ci-windows/master
Okay, that's great. That's exactly what I'd want. A link I can tell a user to click that either gives them the download they'd want, or for the multiple case a page where it's clear they need to pick one.
So, I might be wrong about what OP wanted, but I would still make the suggestion that the nightly.link page could use a short explanation of this variation of the URL format, because it seems very useful to me.
Though, that difference also explains why you thought I should already understand how to get that link. If my link had 2 artifacts, it would have shown the page at that address, clarifying that information, but my link had only 1, so clicking "get links" merely downloaded a zip file for me.
Ohh of course. That's very confusing. My apologies.
Then I think I should actually change the behavior of "get links" for that case.
@bbbradsmith I have made the change https://github.com/oprypin/nightly.link/commit/70081b025a13e3f7476e8257ff8b860ed3fa4dd1 in accordance to this.
If you reach the artifacts page from the main page, there is no longer a difference whether it has 1 or N artifacts - no longer any instant redirect. But if you want the instant redirect, you can drop '?preview' from the URL and it works like before. Still no general solution to the main topic of this issue but maybe we're getting there.
That solution works for me, thanks.
Would it be possible to add a url parameter that converts it to a direct download link? For example:
Single artifact run: https://nightly.link/bbbradsmith/hatariB/workflows/win64/main?download
Multi-artifact run: https://nightly.link/mamedev/mame/workflows/ci-windows/master?download=0 (downloads the first artifact)
To solve the original problem/issue would it be in-scope to support globs? Like https://nightly.link/mamedev/mame/workflows/ci-windows/master/mametiny-windows-clang-*
as the URL or something?