notes by alifeee profile picture rss

return to notes / blog / website / weeknotes / linktree

here I may post some short, text-only notes, mostly about programming. source code.

tags: all (19), scripting (5), bash (4), linux (3), html (2), markdown (2), obsidian (2), shortcuts (2), ActivityPub (1), advent-of-code (1) ............ see all (+15)

viewing a single note

updating a file in a GitHub repository with a workflow # source

tags: github-actions, github, scripting • 196 'words', 59 secs @ 200wpm

often, I want to keep a file in a repository up to date using a script.

here is the most simple example of a workflow that does that, which could be placed in, e.g., .github/workflows/update.yml

name: update stock.txt

on:
  push:
    branches: ["main"]

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: update stock.txt
        run: ./scripts/compute_stock.sh stocktaking.csv > stock.txt

      - name: Commit changes
        uses: stefanzweifel/git-auto-commit-action@v5
        with:
          commit_message: updated stock.txt with latest numbers

This workflow was created for https://github.com/lipu-tenpo/print-and-post to keep a file listing stock up to date with the "logs" of when I acquired and un-acquired stuff.

I initially thought about doing this using Git Hooks, but I want to be able to edit the "logs" from my phone or via a browser, where I wouldn't be able to trigger the git hook.

So, I'm doing it in a proprietary "GitHubby" way, which would be annoying to change if I changed to, say, GitLab. But, here we are. Technology lock-in is real.

back to top back to main page