ChristopherHX / gitea-actions-runner

MIT License
9 stars 2 forks source link

Authorization Error when using sigyl-actions/gitea-action-release-asset with ChristopherHX/gitea-actions-runner Description #6

Closed oilrich25 closed 11 months ago

oilrich25 commented 11 months ago

I have recently switched from using https://gitea.com/gitea/act_runner to ChristopherHX/gitea-actions-runner for my Gitea Actions workflow. Previously, the workflow with https://gitea.com/gitea/act_runner and sigyl-actions/gitea-action-release-asset worked seamlessly, allowing successful compilation and release asset uploads. However, after the switch(ChristopherHX/gitea-actions-runner), I encountered authorization issues with the same sigyl-actions/gitea-action-release-asset.

Note: sigyl-actions/gitea-action-release-asset is a node project

Steps to Reproduce

Use the following action.yaml configuration with https://gitea.com/gitea/act_runner (successfully runs):

name: Build

on:
  push:
    branches: [master]
    paths-ignore: [README.md]
  release:
    types: [published]

defaults:
  run:
    shell: bash
env:
  CACHE_EPOCH: 1
  CCACHE_MAXSIZE: 200M
  CCACHE_MAXFILES: 0
  SCCACHE_CACHE_SIZE: 200M
  GOCACHE: /root/gocache
  XDC_CACHE_HOME: /root/gocache
jobs:
  ubuntu-20:
    runs-on: self-hosted
    steps:
      - uses: actions/checkout@v4
      - name: create gitea release
        uses: sigyl-actions/gitea-action-release-asset@main
        if: ${{ github.event_name == 'release' }}
        with:
          asset: Dockerfile
          asset-name: Dockerfile
          token: ${{ secrets.GITHUB_TOKEN }}

Switch to ChristopherHX/gitea-actions-runner and use the same action.yaml (fails with Unauthorized error).

Expected Behavior

I expect the sigyl-actions/gitea-action-release-asset to run successfully with ChristopherHX/gitea-actions-runner as it did with https://gitea.com/gitea/act_runner.

Actual Behavior

The workflow fails with the following error:

##[error]Unauthorized
oilrich25 commented 11 months ago

Using https://gitea.com/gitea/act_runner, it successfully uploaded release

serverUrl is: http://192.168.1.10:3000
token is: ***
client is: GiteaApi {
  request: FetchHttpRequest {
    config: {
      BASE: 'http://192.168.1.10:3000/api/v1',
      VERSION: '1.17.3',
      WITH_CREDENTIALS: true,
      CREDENTIALS: 'include',
      TOKEN: '***',
      USERNAME: undefined,
      PASSWORD: undefined,
      HEADERS: undefined,
      ENCODE_PATH: undefined
    }
  },
  admin: AdminService { httpRequest: FetchHttpRequest { config: [Object] } },
  issue: IssueService { httpRequest: FetchHttpRequest { config: [Object] } },
  miscellaneous: MiscellaneousService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  notification: NotificationService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  organization: OrganizationService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  package: PackageService { httpRequest: FetchHttpRequest { config: [Object] } },
  repository: RepositoryService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  settings: SettingsService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  user: UserService { httpRequest: FetchHttpRequest { config: [Object] } }
}
owner is: oilrich25
repo is: simple-go-action
(node:135) ExperimentalWarning: buffer.File is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
{
  id: 1676,
  name: 'Dockerfile',
  size: 7307,
  download_count: 0,
  created_at: '2023-12-05T07:36:43Z',
  uuid: '7d186dec-a53a-4e7c-9826-10484e41d4a6',
  browser_download_url: 'http://192.168.1.10:3000/attachments/7d186dec-a53a-4e7c-9826-10484e41d4a6'
}

But if I switch to ChristopherHX/gitea-actions-runner, it will error ##[error]Unauthorized

##[group]Run oilrich25/gitea-action-release-asset@main
with:
  asset: image/Dockerfile
  asset-name: Dockerfile
  token: ***
env:
  CACHE_EPOCH: 1
  CCACHE_MAXFILES: 0
  CCACHE_MAXSIZE: 200M
  GOCACHE: /root/gocache
  SCCACHE_CACHE_SIZE: 200M
  XDC_CACHE_HOME: /root/gocache
##[endgroup]
serverUrl is: http://192.168.1.10:3000
token is: ***
client is: GiteaApi {
  request: FetchHttpRequest {
    config: {
      BASE: 'http://192.168.1.10:3000/api/v1',
      VERSION: '1.17.3',
      WITH_CREDENTIALS: true,
      CREDENTIALS: 'include',
      TOKEN: '***',
      USERNAME: undefined,
      PASSWORD: undefined,
      HEADERS: undefined,
      ENCODE_PATH: undefined
    }
  },
  admin: AdminService { httpRequest: FetchHttpRequest { config: [Object] } },
  issue: IssueService { httpRequest: FetchHttpRequest { config: [Object] } },
  miscellaneous: MiscellaneousService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  notification: NotificationService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  organization: OrganizationService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  package: PackageService { httpRequest: FetchHttpRequest { config: [Object] } },
  repository: RepositoryService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  settings: SettingsService {
    httpRequest: FetchHttpRequest { config: [Object] }
  },
  user: UserService { httpRequest: FetchHttpRequest { config: [Object] } }
}
owner is: oilrich25
repo is: simple-go-action
##[error]Unauthorized
ChristopherHX commented 11 months ago

The action not portable... It honestly hardcodes api/v1.

The GitHub octokit uses ${{ github.api_url }} to allow moving the api endpoint, e.g. for gitea it's api/v1, their GHES has api/v3 at this time..

The ${{ github.server_url }} is the problem, Gitea appended a / to the domain on the server. Then the actions just assumes it doesn't end with / and appends /api/v1 without checking anything https://gitea//api/v1

oilrich25 commented 11 months ago

The action not portable... It honestly hardcodes api/v1.

The GitHub octokit uses ${{ github.api_url }} to allow moving the api endpoint, e.g. for gitea it's api/v1, their GHES has api/v3 at this time..

The ${{ github.server_url }} is the problem, Gitea appended a / to the domain on the server. Then the actions just assumes it doesn't end with / and appends /api/v1 without checking anything https://gitea//api/v1

Can this error be resolved? Or what alternatives are there?

ChristopherHX commented 11 months ago

Fixed in f5496fb020e3cd5d7c9d90c02fcb0bded346b4e9, you can update the runner

oilrich25 commented 11 months ago

Fixed in f5496fb, you can update the runner

After testing, the problem has been successfully solved.