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

Make action compatible with Gitea #1386

Open
bvandevliet opened this issue Apr 24, 2024 · 4 comments
Open

Make action compatible with Gitea #1386

bvandevliet opened this issue Apr 24, 2024 · 4 comments

Comments

@bvandevliet
Copy link

bvandevliet commented Apr 24, 2024

Really want to use this action in my Gitea instance, but it's not compatible and it's trying to use the github API when I look at the runner logs, see below.

It might be easily solved if the action would use the git cli if it is available on the runner machine and falls back to the API method if the git cli is not available. Would this be possible? I believe the checkout action also uses this approach.

EDIT
Simply using git cli won't work as it does not include creating releases. The only way would be to support both the Github and Gitea APIs.

::warning::MyOrg/MyRepo: Invalid config file%0A{%0A  name: 'HttpError',%0A  id: '118',%0A  status: 401,%0A  response: {%0A    url: 'https://api.github.com/repos/MyOrg/MyRepo/contents/.github%252F.gitea%252Frelease-drafter.yml',%0A    status: 401,%0A    headers: {%0A      'access-control-allow-origin': '*',%0A      'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset',%0A      connection: 'close',%0A      'content-length': '80',%0A      'content-security-policy': "default-src 'none'",%0A      'content-type': 'application/json; charset=utf-8',%0A      date: 'Wed, 24 Apr 2024 09:06:33 GMT',%0A      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',%0A      server: 'GitHub.com',%0A      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',%0A      vary: 'Accept-Encoding, Accept, X-Requested-With',%0A      'x-content-type-options': 'nosniff',%0A      'x-frame-options': 'deny',%0A      'x-github-media-type': 'github.v3; param=raw',%0A      'x-github-request-id': 'F232:0F8A:31015FC:3148B4A:6628CB99',%0A      'x-ratelimit-limit': '60',%0A      'x-ratelimit-remaining': '59',%0A      'x-ratelimit-reset': '1713953193',%0A      'x-ratelimit-resource': 'core',%0A      'x-ratelimit-used': '1',%0A      'x-xss-protection': '0'%0A    },%0A    data: {%0A      message: 'Bad credentials',%0A      documentation_url: 'https://docs.github.com/rest'%0A    }%0A  },%0A  request: {%0A    method: 'GET',%0A    url: 'https://api.github.com/repos/MyOrg/MyRepo/contents/.github%252F.gitea%252Frelease-drafter.yml',%0A    headers: {%0A      accept: 'application/vnd.github.v3.raw',%0A      'user-agent': 'probot/12.2.5 octokit-core.js/3.5.1 Node.js/20.12.2 (win32; x64)',%0A      authorization: 'token [REDACTED]'%0A    },%0A    request: {}%0A  },%0A  stack: 'HttpError: Bad credentials\n' +%0A    '    at C:\\Users\\bvandevliet\\.cache\\act\\62485edbd9157925\\act\\actions\\release-drafter-release-drafter@v6.0.0\\dist\\index.js:8462:21\n' +%0A    '    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n' +%0A    '    at async Job.doExecute (C:\\Users\\bvandevliet\\.cache\\act\\62485edbd9157925\\act\\actions\\release-drafter-release-drafter@v6.0.0\\dist\\index.js:30793:18)',%0A  type: 'Error'%0A}
@jetersen
Copy link
Member

jetersen commented Apr 24, 2024

using git client is not efficient and would take too much refactoring.
We use the graphql to achieve most of the workload and this seems like a mistake.
Note the URL include .gitea .github/.gitea/release-drafter.yml. The configName excepts a fileName not the full repostiory path.
I suggest using .github folder cause many other GitHub actions uses this same folder since it is hard coded.

You need to set an environment variables for GHE_HOST to override it to use your gitea API url.

I see no reason why gitea API would not work if they promise 100% compatibility for both REST and GraphQL api.

@bvandevliet
Copy link
Author

Thanks for your comment and suggestion. I've been trying to set it up as you suggested and the url seems to resolve correctly now, but I get another error:

::warning::MyOrg/MyRepo: Invalid config file%0A{%0A  name: 'event',%0A  id: '143',%0A  stack: 'Error: Configuration file .github/release-drafter.yml is not found. The configuration file must reside in your default branch.\n' +%0A    '    at getConfig (C:\\Users\\bvandevliet\\.cache\\act\\da1e3b577c1dc1ad\\act\\actions\\release-drafter-release-drafter@v6.0.0\\dist\\index.js:142745:13)\n' +%0A    '    at async drafter (C:\\Users\\bvandevliet\\.cache\\act\\da1e3b577c1dc1ad\\act\\actions\\release-drafter-release-drafter@v6.0.0\\dist\\index.js:142339:20)\n' +%0A    '    at async Promise.all (index 0)',%0A  type: 'Error'%0A}

However, I have the config file now in /branch/master/.github/release-drafter.yml. Any idea why this error comes up?

@jetersen
Copy link
Member

What did you set the GHE_HOST to and what is your full URL.
Is the .github/release-drafter.yml on the default branch?
Could be master is not your default branch.

@bvandevliet
Copy link
Author

bvandevliet commented Apr 24, 2024

This is what I did:

    steps:
      -
        name: Set GHE_HOST
        id: ghe_host
        run: |
          $ghe_host = $env:GITHUB_SERVER_URL -replace "https://", ""
          echo "::set-output name=GHE_HOST::$ghe_host"
      -
        name: Tag Release
        id: release
        uses: release-drafter/release-drafter@v6.0.0
        with:
          config-name: release-drafter.yml
          prerelease: true
          prerelease-identifier: 'alpha'
          token: ${{ github.token }}
        env:
          GHE_HOST: ${{ steps.ghe_host.outputs.GHE_HOST }}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants