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

Update gist failed in git action #98

Closed
southouse opened this issue Aug 11, 2023 · 6 comments
Closed

Update gist failed in git action #98

southouse opened this issue Aug 11, 2023 · 6 comments

Comments

@southouse
Copy link

I following this README.md. But I failed to git action in update gist.

I set project secret variable to correctly (GIT_TOKEN, GIST_ID) and My git credential token is not expired.

What`s happen? I want solved.

[failed action]
Screenshot 2023-08-11 at 15 57 17

[repository secrets setting]
Screenshot 2023-08-11 at 16 00 15

[.github/workflows/schedule.yml]
Screenshot 2023-08-11 at 16 03 10

@maxam2017
Copy link
Owner

For trouble shooting, try this workflow on your local environment.

Step1: clone project

git clone https://github.com/maxam2017/productive-box

Step2: install deps

yarn

Step3: add environment variables

touch .env

and add few lines of env variable

# example of .env file
GH_TOKEN=ghp_oooxxooxx
GIST_ID=oxoxoxox
TIMEZONE=Asia/Taipei

⚠️ make sure https://gist.github.com/<username>/<GIST_ID> exists.

Step4: trigger gist file updating

yarn dev

and check if your gist file update correctly.

If you encounter something wrong, feel free to report here.

@southouse
Copy link
Author

I tried your comment but following this error.

~/workspace/southouse/git/productive-box master ❯ yarn dev                                                                                                                      14:28:13
yarn run v1.22.19
$ ts-node src/index.ts
/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:859
    return new TSError(diagnosticText, diagnosticCodes, diagnostics);
           ^
TSError: ⨯ Unable to compile TypeScript:
src/index.ts:40:15 - error TS7006: Parameter 'repoInfo' implicitly has an 'any' type.

40       .filter(repoInfo => !repoInfo?.isFork)
                 ~~~~~~~~
src/index.ts:41:12 - error TS7006: Parameter 'repoInfo' implicitly has an 'any' type.

41       .map(repoInfo => ({
              ~~~~~~~~
src/index.ts:64:7 - error TS7006: Parameter 'edge' implicitly has an 'any' type.

64       edge => {
         ~~~~

    at createTSError (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:859:12)
    at reportTSError (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:863:19)
    at getOutput (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:1077:36)
    at Object.compile (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:1433:41)
    at Module.m._compile (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:1617:30)
    at Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/southouse/workspace/southouse/git/productive-box/node_modules/ts-node/src/index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1004:32)
    at Function.Module._load (node:internal/modules/cjs/loader:839:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  diagnosticCodes: [ 7006, 7006, 7006 ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@southouse
Copy link
Author

southouse commented Sep 4, 2023

I resolve this error. I created tsconfig.json and write below content.

{
     "isolatedModules": false
 }

But I have another error. please checked to my setting files before check error log

my gist url: https://gist.github.com/southouse/976cd730b9a94c596046da7e5c75e12e

.env file

 GH_TOKEN=${MY_GH_TOKEN}
 GIST_ID=976cd730b9a94c596046da7e5c75e12e
 TIMEZONE=Asia/Seoul

following this error log.

~/workspace/southouse/git/productive-box master* 6s ❯ yarn dev                                                                                                                  14:50:06
yarn run v1.22.19
$ ts-node src/index.ts
RequestError [HttpError]: Not Found
    at /Users/southouse/workspace/southouse/git/productive-box/node_modules/@octokit/rest/node_modules/@octokit/request/dist-src/fetch-wrapper.js:68:27
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 404,
  response: {
    url: 'https://api.github.com/gists/d8b503d46060afa60cc8f5fe20c0a0e8',
    status: 404,
    headers: {
      'access-control-allow-origin': '*',
      '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',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Mon, 04 Sep 2023 05:50:11 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-oauth-scopes': '',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'F4F0:3597:71F25E:851A3F:64F57013',
      'x-oauth-scopes': 'project, repo, write:packages',
      'x-ratelimit-limit': '100',
      'x-ratelimit-remaining': '94',
      'x-ratelimit-reset': '1693809408',
      'x-ratelimit-resource': 'gist_update',
      'x-ratelimit-used': '6',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest/gists/gists#update-a-gist'
    }
  },
  request: {
    method: 'PATCH',
    url: 'https://api.github.com/gists/d8b503d46060afa60cc8f5fe20c0a0e8',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/17.11.2 octokit-core.js/2.5.4 Node.js/16.17.0 (macOS Unknown; arm64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: `{"files":{"gistfile1.txt":{"filename":"I'm an early 🐤","content":"🌞 Morning    27 commits  ████▍░░░░░░░░░░░░░░░░  21.4%\\n🌆 Daytime    65 commits  ██████████▊░░░░░░░░░░  51.6%\\n🌃 Evening    30 commits  ████▉░░░░░░░░░░░░░░░░  23.8%\\n🌙 Night       4 commits  ▋░░░░░░░░░░░░░░░░░░░░   3.2%"}}}`,
    request: { hook: [Function: bound bound register] }
  }
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@maxam2017
Copy link
Owner

Inside the error log, the gist id d8b503d46060afa60cc8f5fe20c0a0e8 is not the same as your .env file provided. Please check if your env file load correctly.

@southouse
Copy link
Author

I retry this problem with updated .env file. but following this error.

~/workspace/southouse/git/productive-box master* ❯ yarn dev                                                                                                                     13:06:23
yarn run v1.22.19
$ ts-node src/index.ts
RequestError [HttpError]: Not Found
    at /Users/southouse/workspace/southouse/git/productive-box/node_modules/@octokit/rest/node_modules/@octokit/request/dist-src/fetch-wrapper.js:68:27
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  status: 404,
  response: {
    url: 'https://api.github.com/gists/976cd730b9a94c596046da7e5c75e12e',
    status: 404,
    headers: {
      'access-control-allow-origin': '*',
      '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',
      connection: 'close',
      'content-encoding': 'gzip',
      'content-security-policy': "default-src 'none'",
      'content-type': 'application/json; charset=utf-8',
      date: 'Tue, 05 Sep 2023 04:06:34 GMT',
      'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
      server: 'GitHub.com',
      'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
      'transfer-encoding': 'chunked',
      vary: 'Accept-Encoding, Accept, X-Requested-With',
      'x-accepted-oauth-scopes': '',
      'x-content-type-options': 'nosniff',
      'x-frame-options': 'deny',
      'x-github-api-version-selected': '2022-11-28',
      'x-github-media-type': 'github.v3; format=json',
      'x-github-request-id': 'D085:4738:12E2CD:162B47:64F6A949',
      'x-oauth-scopes': 'project, repo, write:packages',
      'x-ratelimit-limit': '100',
      'x-ratelimit-remaining': '99',
      'x-ratelimit-reset': '1693890394',
      'x-ratelimit-resource': 'gist_update',
      'x-ratelimit-used': '1',
      'x-xss-protection': '0'
    },
    data: {
      message: 'Not Found',
      documentation_url: 'https://docs.github.com/rest/gists/gists#update-a-gist'
    }
  },
  request: {
    method: 'PATCH',
    url: 'https://api.github.com/gists/976cd730b9a94c596046da7e5c75e12e',
    headers: {
      accept: 'application/vnd.github.v3+json',
      'user-agent': 'octokit-rest.js/17.11.2 octokit-core.js/2.5.4 Node.js/16.17.0 (macOS Unknown; arm64)',
      authorization: 'token [REDACTED]',
      'content-type': 'application/json; charset=utf-8'
    },
    body: `{"files":{"abc":{"filename":"I'm an early 🐤","content":"🌞 Morning    27 commits  ████▍░░░░░░░░░░░░░░░░  20.9%\\n🌆 Daytime    68 commits  ███████████░░░░░░░░░░  52.7%\\n🌃 Evening    30 commits  ████▉░░░░░░░░░░░░░░░░  23.3%\\n🌙 Night       4 commits  ▋░░░░░░░░░░░░░░░░░░░░   3.1%"}}}`,
    request: { hook: [Function: bound bound register] }
  }
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@levelingup
Copy link
Contributor

You ever get this working? I was running into the issue as well when you were seeing the typescript error. I was able to get it working after adding

interface RepoInfo {
  name: string;
  owner: {
    login: string;
  };
  isFork: boolean;
}

interface Edge {
  node: {
    committedDate: string;
  };
}

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

3 participants