opentofu / setup-opentofu

Mozilla Public License 2.0
84 stars 10 forks source link

Gitea CI compatibility with a small change #21

Closed nicolas-brousse closed 8 months ago

nicolas-brousse commented 8 months ago

Trying to use this action in my Gitea repository and CI. Gitea runner is really close to GitHub runner and follow a lot of common configuration to be mostly compliant with exiting GH actions.

Gitea use GITHUB_TOKEN env var but I guess the token is in really a Gitea token. So this make the getRelease method fail (failed fetching releases).

To fix that I moved the process.env.GITHUB_TOKEN call in an action input. So I'm able to do the following:

      - name: Setup OpenTofu
        uses: nicolas-brousse/setup-opentofu@gitea-compatibility
        with:
          github_token: ~

Bit the way I make github_token input action use github token by default, to make the action will still run as actually on GitHub runners.

I can imagine you are not intent to maintain your action for other services than GitHub, but since this is a minimal change, I'm opening this PR.

Let me know what do you think about, and if you need some changes from me.

ghost commented 8 months ago

Hi @nicolas-brousse thank you for this PR, I am all for enabling Gitea users, so this is a good change.

There's one edge case missing from your code: when someone specified a GitHub Token from an environment variable other than the default GitHub token, such as a secret. It's extremely unlikely, but could happen. Could you please modify your code to read from both the input and the environment variable and prefer the environment variable if set for compatibility?

Also, your commit is missing a DCO signoff. Could you please add that?

Great work, thank you for making this!

nicolas-brousse commented 8 months ago

@janosdebugs happy that this feature is something you're for.

I've just updated my commit to add DCO signoff.

There's one edge case missing from your code: when someone specified a GitHub Token from an environment variable other than the default GitHub token, such as a secret. It's extremely unlikely, but could happen. Could you please modify your code to read from both the input and the environment variable and prefer the environment variable if set for compatibility?

I understand, but if I do this I'll have the same issue that I've got by using main branch. Since Gitea runner always set GITHUB_TOKEN env, it will always enter the condition, that's why I try with an action input.

I tried to force GITHUB_TOKEN to be empty or null on workflow and specific step, but the variable seems to be set.

I'll try to do some more tests.

nicolas-brousse commented 8 months ago

Hi @nicolas-brousse unfortunately, this won't work and will break GitHub. Would you want @bencurio and myself to take care of it in a separate PR? I can make the changes and @bencurio has a Forgejo instance available for testing.

Hi @janosdebugs, sure. Feel free if it's more comfortable for you. I'll also be available to do some tests on my Gitea instance if you want by the way.

ghost commented 8 months ago

Hey @nicolas-brousse could you give #23 (forgejo-support branch) a try please?

nicolas-brousse commented 8 months ago

@janosdebugs it works on Gitea runner :relieved:

ghost commented 8 months ago

Thanks @nicolas-brousse I'll try to get that merged then. Closing in favor of #23

ghost commented 8 months ago

Hey @nicolas-brousse thank you for your patience. ~You can use it by referencing the commit ID directly: da3271e0a2f8b8552a91e37cf85d03622c328ab7. I'll try to get this into a proper release soon too.~ Shipped as v1.0.2. :)