github-activity-readme icon indicating copy to clipboard operation
github-activity-readme copied to clipboard

my workflow for recent activity is not working.

Open kholdarboev opened this issue 2 years ago β€’ 10 comments

Screenshot 2022-05-16 165905

kholdarboev avatar May 17 '22 00:05 kholdarboev

image this is my yml file

kholdarboev avatar May 17 '22 00:05 kholdarboev

also having this error

KarmaBlackshaw avatar Jun 14 '22 05:06 KarmaBlackshaw

got this error this morning

hi-reeve avatar Jun 24 '22 02:06 hi-reeve

Same Here

pAkalpa avatar Aug 05 '22 18:08 pAkalpa

Any update on this?

fbuireu avatar Aug 11 '22 05:08 fbuireu

Any update on this?

I had faced the same problem. But I solved the problem eventually. Here are my codes.

YML file

name: Update README

on:
  schedule:
    - cron: '*/30 * * * *'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    name: Update this repo's README with recent activity

    steps:
      - uses: actions/checkout@v2
      - uses: jamesgeorge007/github-activity-readme@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Copy all the codes. If you only copy and paste the <start section> and <end section> in README file. It will not be work.

# :zap: Recent Activity

<!--START_SECTION:activity-->
1. πŸŽ‰ Merged PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
2. πŸ’ͺ Opened PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
3. πŸ—£ Commented on [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
4. ❗️ Closed issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
5. ❗️ Opened issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
<!--END_SECTION:activity-->

Here is my repo : https://github.com/NyanKaungSet/Github-Workflow/blob/master/README.md#Recent_Actvity

If the workflow failed, make sure you created GITHUB_TOKEN with following scopes in your Personal access tokens.

  • admin:public_key
  • gist
  • notifications
  • workflow
  • write:packages

I hoped this may be helpful.

NyanKaungSet avatar Aug 16 '22 14:08 NyanKaungSet

I had faced the same problem. But I solved the problem eventually. Here are my codes.

YML file

name: Update README

on:
  schedule:
    - cron: '*/30 * * * *'
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    name: Update this repo's README with recent activity

    steps:
      - uses: actions/checkout@v2
      - uses: jamesgeorge007/github-activity-readme@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Copy all the codes. If you only copy and paste the <start section> and <end section> in README file. It will not be work.

# :zap: Recent Activity

<!--START_SECTION:activity-->
1. πŸŽ‰ Merged PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
2. πŸ’ͺ Opened PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
3. πŸ—£ Commented on [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
4. ❗️ Closed issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
5. ❗️ Opened issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
<!--END_SECTION:activity-->

Here is my repo : https://github.com/NyanKaungSet/Github-Workflow/blob/master/README.md#Recent_Actvity

If the workflow failed, make sure you created GITHUB_TOKEN with following scopes in your Personal access tokens.

  • admin:public_key
  • gist
  • notifications
  • workflow
  • write:packages

I hoped this may be helpful.

I can confirm that it is still not working.

Here is the last output using the same configuration you mentioned:

Run jamesgeorge007/github-activity-readme@master
⬀  debug     Getting activity for fbuireu
⬀  debug     Activity for fbuireu, [10](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:11)0 events found.
βœ”  success   Wrote to README
⬀  debug     Something went wrong
βœ–  fatal     Error: Invalid status code: 1 
    at ChildProcess.<anonymous> (/home/runner/work/_actions/jamesgeorge007/github-activity-readme/master/dist/index.js:1530:15)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Socket.<anonymous> (internal/child_process.js:444:[11](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:12))
    at Socket.emit (events.js:314:20)
    at Pipe.<anonymous> (net.js:675:[12](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:13))

My GITHUB_TOKEN has the exact permissions you mentioned and following the stack trace of the error, where success appears (βœ” success) it doesn't look like permission issues.

Moreover, my README.md file has the comments needed by the action:

### Latest Activity
<!--START_SECTION:activity-->
<!--END_SECTION:activity-->

fbuireu avatar Aug 16 '22 15:08 fbuireu

I can confirm that it is still not working.

As I mentioned above, Your README file only have these lines.

<!--START_SECTION:activity-->
<!--END_SECTION:activity-->

Delete those 2 lines and add the following codes. Save it and run the workflow. If this still doesn’t work, I will fork your repo and try from my side.

<!--START_SECTION:activity-->
1. πŸŽ‰ Merged PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
2. πŸ’ͺ Opened PR [#90](https://github.com/CartimDraluc/Cartimpedia/pull/90) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
3. πŸ—£ Commented on [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
4. ❗️ Closed issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
5. ❗️ Opened issue [#89](https://github.com/CartimDraluc/Cartimpedia/issues/89) in [CartimDraluc/Cartimpedia](https://github.com/CartimDraluc/Cartimpedia)
<!--END_SECTION:activity-->

NyanKaungSet avatar Aug 16 '22 15:08 NyanKaungSet

Sorry, but it doesn't make sense at all what you are suggesting. Everything wrapped by <!--START_SECTION:activity--> is replaced by the action's code (what extracts from GitHub's activity). If that was the problem, it would never work because it would be never able to replace the content inside the <!--START_SECTION:activity--> section.

I've also tried just to be sure, and it doesn't work, indeed.

I have my own version of the action (see https://github.com/jamesgeorge007/github-activity-readme/pull/79) where we add a TARGET_FILE option, but I've also tried using the base configuration (the default one) and the one you suggested, and it still doesn't work. Feel free to fork if you want.

fbuireu avatar Aug 16 '22 16:08 fbuireu

For those who are facing this issue:

Run jamesgeorge007/github-activity-readme@master
⬀  debug     Getting activity for fbuireu
⬀  debug     Activity for fbuireu, [10](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:11)0 events found.
βœ”  success   Wrote to README
⬀  debug     Something went wrong
βœ–  fatal     Error: Invalid status code: 1 
    at ChildProcess.<anonymous> (/home/runner/work/_actions/jamesgeorge007/github-activity-readme/master/dist/index.js:1530:15)
    at ChildProcess.emit (events.js:314:20)
    at maybeClose (internal/child_process.js:1022:16)
    at Socket.<anonymous> (internal/child_process.js:444:[11](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:12))
    at Socket.emit (events.js:314:20)
    at Pipe.<anonymous> (net.js:675:[12](https://github.com/fbuireu/fbuireu/runs/7861274323?check_suite_focus=true#step:3:13))

After a long debugging, it seems that the issue is related to the permissions or security of the repo/branch. The CI GitHub action works as intended (see βœ” success message) however, it seems that after that, is not able to push or to apply the changes to the given file and because of the lack of debug errors it's easy to lose the trace of the issue.

Make sure that you are not locking or protecting the main/master branch whatsoever. Personally, I think that it should be added as a feature to bypass or to have a security feature to write in the protected branches (that's why the token is) but in the meantime, this is a workaround.

After I removed the protections, the action worked as intended.

image

fbuireu avatar Aug 17 '22 10:08 fbuireu

Just add the following permission flag to allow github actions to update the contents of your repository:

name: GitHub Activity

on:
  workflow_dispatch:
  schedule:
    - cron: "0 0 * * *"

jobs:
  build:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v3
      - uses: jamesgeorge007/github-activity-readme@master
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

This way a token with write/commit privileges will be created. I have changed the README.md to reflect this necessary change.

tuunit avatar May 30 '23 21:05 tuunit