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
The file structure is as following:
.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