# Using github actions to the count number of nodes in Org-roam

**URL:** <https://org-roam.discourse.group/t/using-github-actions-to-the-count-number-of-nodes-in-org-roam/559>\
**Category:** Tips\
**Created:** [July 25, 2020, 10:11pm UTC](https://org-roam.discourse.group/t/using-github-actions-to-the-count-number-of-nodes-in-org-roam/559 "2020-07-25T22:11:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cool\_ran](https://yyz2.discourse-cdn.com/free1/user_avatar/org-roam.discourse.group/cool_ran/32/130_2.png) [@cool\_ran](https://org-roam.discourse.group/u/cool_ran)\
**Post date:** [July 25, 2020, 10:11pm UTC](https://org-roam.discourse.group/t/using-github-actions-to-the-count-number-of-nodes-in-org-roam/559/1 "2020-07-25T22:11:12Z")

</div>

I want to see how many ideas I have in my external brain, so I study  
how to use github action to achieve this.

Example is like this:

I now have ![image](https://global.discourse-cdn.com/free1/uploads/orgroam/original/1X/20220e885588339c1de67d9d6adda98ce9f56383.png)

The file structure is as following:

```auto
.github/
 \_ .how-many-ideas.txt
README-tmp.md
README.md

```

The idea is to replace the template variable (`ROAM_NUM`) in  
`README-tmp.md` using github action. `how-many-ideas.txt` stores the  
number of the nodes after each commit.

The action code is:

```
name: commitfiles
on: [push]

jobs:
  job1:
    runs-on: [ubuntu-latest]
    steps:
      - name: checkout
        uses: actions/checkout@v2
      - name: Modify value # Tried to modify the files based on existing testfile.txt
        run: |
          echo "$(date) $(git ls-files | grep "\.org$" | wc -l) $line" >> how-many-ideas.txt
          ROAM_NUM=$(git ls-files | grep "\.org$" | wc -l)
          sed "s/ROAM_NUM/${ROAM_NUM}/g" README-tmp.md > README.md

      - name: move to dir # Move the generated files into output folder
        run: |
          yes| cat how-many-ideas.txt >> .github/how-many-ideas.txt
      - name: Commit files # commit the output folder
        run: |
          git config --local user.email "IamBOT@github.com"
          git config --local user.name "BOT"
          git add .github/how-many-ideas.txt
          git add README.md
          git commit -m "Good Jobs, You Brain is expanding."
      - name: Push changes # push the output folder to your repo
        uses: ad-m/github-push-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          force: true
```
