getmeli / meli

Platform for deploying static sites and frontend applications easily. Automatic SSL, deploy previews, reverse proxy, and more.
Other
2.4k stars 97 forks source link

Not Support Gitea Actions Request failed with status code 404 #264

Closed seepine closed 6 months ago

seepine commented 7 months ago

yml

name: Deploy Meli

on:
  push:
env:
  GITEA_TOKEN: ${{ secrets.GIT_TOKEN }}
jobs:
  setup:
    if: ${{ secrets.MELI_TOKEN != '' }}
    runs-on: ubuntu-latest
    container: seepine/ubuntu:act
    steps:
      - name: Checkout
        uses: actions/checkout@v3
        with:
          fetch-depth: 1

      - name: Get Meta
        id: meta
        run: |
          echo name=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT
          echo version=$(echo ${{ github.ref }} | awk -F"/" '{print $3}' | awk -F"v" '{print $2}') >> $GITHUB_OUTPUT
          echo branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}} >> $GITHUB_OUTPUT          

      - name: Echo Meta
        run: |
          echo ${{ steps.meta.outputs.name }}
          echo ${{ steps.meta.outputs.version }}
          echo ${{ steps.meta.outputs.branch }}
          echo ${{ env.GITHUB_SHA }}

      - name: Upload
        run: |
          npx @getmeli/cli upload ${{ secrets.MELI_PATH }} \
            --url ${{ secrets.MELI_URL }} \
            --site ${{ secrets.MELI_SITE }} \
            --token ${{ secrets.MELI_TOKEN }} \
            --branch ${{ steps.meta.outputs.branch }} \
            --release ${{ env.GITHUB_SHA }}

Error log

npm WARN exec The following package was not found and will be installed: @getmeli/cli@1.2.0
 Meli CLI v1.[2](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-2).0 - 2021-02-18T15:21:14.925Z - 1b91ee6c[3](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-3)176adf87c1dde6d875b[4](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-4)2703e2a0d09
fec4039b7c6a 14[5](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-5) 2024-01-29T09:19:53.186Z info  meli.cli:upload Compressing files from ***.... 
fec4039b7c[6](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-6)a 145 2024-01-29T09:19:53.372Z info  meli.cli:upload Uploading release to ***... 
fec4039b[7](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-7)c6a 145 2024-01-29T09:20:03.509Z info  meli.cli:uploadArchive Your site has been deployed at: 
fec4039b7c6a 145 2024-01-29T09:20:03.509Z info  meli.cli:uploadArchive - https://main.lottery.pages.com: 
fec4039b7c6a 145 2024-01-29T09:20:03.509Z info  meli.cli:setCommitStatus Setting Github commit status 
r [Error]: Request failed with status code 404
    at /root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commons/axios/ensure-stack-trace.ts:11:3[8](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-8)
    at process.options (node:internal/process/task_queues:[9](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-9)5:5)
    at t.Github.GITHUB_SERVER_URL [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/github.ts:33:5)
    at Object.deployUrl [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/set-commit-status.ts:31:69)
    at Object.url [as uploadArchive] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload-archive.ts:46:22)
    at Object.t.upload (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload.ts:17:47) {
  error: Error: Request failed with status code 404
      at createError (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/core/createError.js:16:15)
      at settle (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/core/settle.js:17:12)
      at IncomingMessage.handleStreamEnd (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/adapters/http.js:269:[11](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-11))
      at IncomingMessage.emit (node:events:529:35)
      at endReadableNT (node:internal/streams/readable:1400:[12](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-12))
      at processTicksAndRejections (node:internal/process/task_queues:82:21)
  Error: Thrown at:
      at /root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commons/axios/ensure-stack-trace.ts:7:36
      at process.options (node:internal/process/task_queues:95:5)
      at t.Github.GITHUB_SERVER_URL [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/github.ts:33:5)
      at Object.deployUrl [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/set-commit-status.ts:31:69)
      at Object.url [as uploadArchive] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload-archive.ts:46:22)
      at Object.t.upload (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload.ts:17:47) {
    config: {
      url: '/repos/demo/lottery/statuses/87cb97c27dba605adccbefd[13](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-13)033b7091e31a6b7',
      method: 'post',
      data: '{"context":"meli","description":"Release 87cb97c27dba605adccbefd13033b7091e31a6b7 deployed to Meli","state":"success","target_url":"https://main.lottery.pages.com:"}',
      headers: [Object],
      baseURL: 'https://git.example.com/api/v3',
      transformRequest: [Array],
      transformResponse: [Array],
      timeout: 0,
      adapter: [Function: httpAdapter],
      xsrfCookieName: 'XSRF-TOKEN',
      xsrfHeaderName: 'X-XSRF-TOKEN',
      maxContentLength: -1,
      maxBodyLength: -1,
      validateStatus: [Function: validateStatus],
      transitional: [Object],
      errorContext: Error: Thrown at:
          at /root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commons/axios/ensure-stack-trace.ts:7:36
          at process.options (node:internal/process/task_queues:95:5)
          at t.Github.GITHUB_SERVER_URL [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/github.ts:33:5)
          at Object.deployUrl [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/set-commit-status.ts:31:69)
          at Object.url [as uploadArchive] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload-archive.ts:46:22)
          at Object.t.upload (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload.ts:17:47)
    },
    request: ClientRequest {
      _events: [Object: null prototype],
      _eventsCount: 7,
      _maxListeners: undefined,
      outputData: [],
      outputSize: 0,
      writable: true,
      destroyed: false,
      _last: true,
      chunkedEncoding: false,
      shouldKeepAlive: false,
      maxRequestsOnConnectionReached: false,
      _defaultKeepAlive: true,
      useChunkedEncodingByDefault: true,
      sendDate: false,
      _removedConnection: false,
      _removedContLen: false,
      _removedTE: false,
      strictContentLength: false,
      _contentLength: 171,
      _hasBody: true,
      _trailer: '',
      finished: true,
      _headerSent: true,
      _closed: false,
      socket: [TLSSocket],
      _header: 'POST /api/v3/repos/demo/lottery/statuses/87cb97c27dba605adccbefd13033b7091e31a6b7 HTTP/1.1\r\n' +
        'Accept: application/json, text/plain, */*\r\n' +
        'Content-Type: application/json\r\n' +
        'Authorization: token ***\r\n' +
        'User-Agent: axios/0.21.4\r\n' +
        'Content-Length: 171\r\n' +
        'Host: git.example.com\r\n' +
        'Connection: close\r\n' +
        '\r\n',
      _keepAliveTimeout: 0,
      _onPendingData: [Function: nop],
      agent: [Agent],
      socketPath: undefined,
      method: 'POST',
      maxHeaderSize: undefined,
      insecureHTTPParser: undefined,
      joinDuplicateHeaders: undefined,
      path: '/api/v3/repos/demo/lottery/statuses/87cb97c27dba605adccbefd13033b7091e31a6b7',
      _ended: true,
      res: [IncomingMessage],
      aborted: false,
      timeoutCb: null,
      upgradeOrConnect: false,
      parser: null,
      maxHeadersCount: null,
      reusedSocket: false,
      host: 'git.example.com',
      protocol: 'https:',
      _redirectable: [Writable],
      [Symbol(kCapture)]: false,
      [Symbol(kBytesWritten)]: 0,
      [Symbol(kNeedDrain)]: false,
      [Symbol(corked)]: 0,
      [Symbol(kOutHeaders)]: [Object: null prototype],
      [Symbol(errored)]: null,
      [Symbol(kHighWaterMark)]: 16384,
      [Symbol(kRejectNonStandardBodyWrites)]: false,
      [Symbol(kUniqueHeaders)]: null
    },
    response: {
      status: 404,
      statusText: 'Not Found',
      headers: [Object],
      config: [Object],
      request: [ClientRequest],
      data: 'Not found.\n'
    },
    isAxiosError: true,
    toJSON: [Function: toJSON]
  }
}
{
  "errorObject": {
    "message": "Request failed with status code 404",
    "name": "Error",
    "stack": "Error: Request failed with status code 404\n    at createError (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/core/createError.js:16:15)\n    at settle (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/core/settle.js:17:12)\n    at IncomingMessage.handleStreamEnd (/root/.npm/_npx/dc9337df1940ee5e/node_modules/axios/lib/adapters/http.js:269:11)\n    at IncomingMessage.emit (node:events:529:35)\n    at endReadableNT (node:internal/streams/readable:[14](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-14)00:12)\n    at processTicksAndRejections (node:internal/process/task_queues:82:21)\nError: Thrown at:\n    at /root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commons/axios/ensure-stack-trace.ts:7:36\n    at process.options (node:internal/process/task_queues:95:5)\n    at t.Github.GITHUB_SERVER_URL [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/github.ts:33:5)\n    at Object.deployUrl [as setCommitStatus] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/notify-git/set-commit-status.ts:31:69)\n    at Object.url [as uploadArchive] (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload-archive.ts:46:22)\n    at Object.t.upload (/root/.npm/_npx/dc9337df1940ee5e/node_modules/@getmeli/cli/src/commands/upload/upload.ts:[17](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-17):47)",
    "config": {
      "url": "/repos/demo/lottery/statuses/87cb97c27dba605adccbefd13033b7091e31a6b7",
      "method": "post",
      "data": "{\"context\":\"meli\",\"description\":\"Release 87cb97c27dba605adccbefd13033b7091e31a6b7 deployed to Meli\",\"state\":\"success\",\"target_url\":\"https://main.lottery.pages.com:\"}",
      "headers": {
        "Accept": "application/json, text/plain, */*",
        "Content-Type": "application/json",
        "Authorization": "token ***",
        "User-Agent": "axios/0.21.4",
        "Content-Length": 171
      },
      "baseURL": "https://git.example.com/api/v3",
      "transformRequest": [
        null
      ],
      "transformResponse": [
        null
      ],
      "timeout": 0,
      "xsrfCookieName": "XSRF-TOKEN",
      "xsrfHeaderName": "X-XSRF-TOKEN",
      "maxContentLength": -1,
      "maxBodyLength": -1,
      "transitional": {
        "silentJSONParsing": true,
        "forcedJSONParsing": true,
        "clarifyTimeoutError": false
      },
      "errorContext": {}
    }
  },
  "response": {
    "status": 404,
    "statusText": "Not Found",
    "headers": {
      "server": "nginx",
      "date": "Mon, 29 Jan [20](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-20)[24](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-24) 09:20:03 GMT",
      "content-type": "text/plain;charset=utf-8",
      "content-length": "11",
      "connection": "close",
      "cache-control": "max-age=0, private, must-revalidate, no-transform",
      "set-cookie": [
        "i_like_gitea=6db01fd6b24f9809; Path=/; HttpOnly; Secure; SameSite=Lax",
        "_csrf=YMXQo-pUJkK[27](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-27)oFAcZzySi5NOlc6MTcwNjUyMDAwMzU4NDQzMjgyMA; Path=/; Max-Age=86[40](https://git.example.com/demo/lottery/actions/runs/7#jobstep-4-40)0; HttpOnly; Secure; SameSite=Lax"
      ],
      "x-content-type-options": "nosniff",
      "x-frame-options": "SAMEORIGIN"
    },
    "data": "Not found.\n"
  }
}
seepine commented 6 months ago

meli-cli/upload/set-commit-status I found the problem, gitea set GITHUB_TOKEN default , and cli judge github token first, so it run github api everytime

if (process.env.GITHUB_TOKEN) {
  ...
} else {
    logger.debug('Github token not found, will not set commit status');
}
seepine commented 6 months ago

It can be work

      - name: Upload
        env:
          GITHUB_TOKEN: ''
          GITEA_TOKEN: ${GITHUB_TOKEN}
          GITEA_URL: ${GITHUB_SERVER_URL}
        run: |
          npx @getmeli/cli upload ./ \
            --url ${{ secrets.MELI_URL }} \
            --site ${{ secrets.MELI_SITE }} \
            --token ${{ secrets.MELI_TOKEN }} \
            --branch ${GITHUB_REF_NAME} \
            --release ${{ env.GITHUB_SHA }}