configurator icon indicating copy to clipboard operation
configurator copied to clipboard

Infer some values for Github Release

Open RichiCoder1 opened this issue 4 years ago • 5 comments

Having used this action a few times now, I think there's some possibility to make the action a bit less boilerplate-y.

Specifically, if the user specifies a urlTemplate that matches ^https:\/\/github\.com\/(?<repo>.*\/.*)\/releases\/download\/, infer the following:

fromGithubReleases: true
repo: <repo from regex>
version: latest

So that this:

      - uses: engineerd/[email protected]
        with:
          name: "kind"
          fromGitHubReleases: "true"
          repo: "kubernetes-sigs/kind"
          urlTemplate: "https://github.com/kubernetes-sigs/kind/releases/download/{{version}}/kind-linux-amd64"
          version: "latest"
          token: ${{ secrets.GITHUB_TOKEN }}

would become this:

      - uses: engineerd/[email protected]
        with:
          name: "kind"
          urlTemplate: "https://github.com/kubernetes-sigs/kind/releases/download/{{version}}/kind-linux-amd64"
          token: ${{ secrets.GITHUB_TOKEN }}

RichiCoder1 avatar Jul 15 '21 19:07 RichiCoder1

Hi, and thanks for opening this issue!

Why would version automatically become "latest"?

radu-matei avatar Jul 15 '21 20:07 radu-matei

Mostly to have a default in place, though I'd be fine leaving that out to force consumers to think about versioning and pinning the version.

RichiCoder1 avatar Jul 15 '21 21:07 RichiCoder1

Ok, that makes sense. As long as it's clear in the documentation (readme for now) that the URL location and repository can be disconnected (i.e. in a lot of cases, the binary assets are stored in some cloud accounts), I'm ok with this change.

Would you be interested in contributing? I'm happy to help / review, but it would probably take me a few weeks to get back to adding this. The changes seem to be when we make the decision to get a GitHub release -- here we would change the condition to test for a urlTemplate as well, then try to infer the GitHub repository:

https://github.com/engineerd/configurator/blob/94e10ecef5d996565e35a78795802d8bd86f8fb2/src/configurator.ts#L75-L81

radu-matei avatar Jul 15 '21 23:07 radu-matei

I can def contribute that :)

RichiCoder1 avatar Jul 16 '21 00:07 RichiCoder1

Done! Lmk if it looks good: https://github.com/engineerd/configurator/pull/30

RichiCoder1 avatar Jul 16 '21 03:07 RichiCoder1