Automatically update data and commit

Automatically update data and commit

My Workflow

I just wrote an article about Github Actions, but I don’t want to deprive you of this one! What is it about? For a single page application, various data sources are tapped. However, some data cannot be loaded directly from the application. For this reason I wrote a script that pulls, aggregates and formats the data.

In order for the data to be delivered with the application it must be committed into the repo. Then the regular CI pipeline runs, which builds and publishes the app:

diagram of the workflow

The nice thing is that I don’t have to do anything else, because the Github action runs itself on a regular basis, and every time it commits to the main branch, the CI pipeline runs.

The application was about getting a POC up and running quickly to tap into data from various sources and prepare it accordingly.

The Github workflow consists of three main parts:

  1. Setup
  2. Execute script
  3. Commit and push
name: Update Polls and Execs

    - cron: "5 18 * * 1"

    name: Update Polls and Execs
    runs-on: ubuntu-latest
      - uses: actions/checkout@v1

      - uses: actions/setup-node@v1
          node-version: 14
      - run: npm install

      - name: Run script to update data
        run: npm run index

      - name: Push data
        uses: test-room-7/action-update-file@v1
          file-path: |
          commit-msg: chore(data) update polls and execs
          github-token: ${{ secrets.GITHUB_TOKEN }}

The exciting thing about this action is the scheduled execution. Not everyone may be aware of this, but it can be used to map cron jobs that do their regular work.

Additional Resources / Info

Have fun!

github node typescript github-actions
Published on 2021-11-25, last updated on 2024-05-28 by Adam
Comments or questions? Open a new discussion on github.
Adam Urban

Adam Urban is fullstack engineer, loves serverless and generative art, and is building side projects like, and in his free time.