DEV Community

Cover image for Automatically update data and commit

Posted on • Updated on • Originally published at

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.

Submission Category: Maintainer Must-Haves

Yaml File or Link to Code

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 }}
Enter fullscreen mode Exit fullscreen mode

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

[Note:] # (Be sure to link to any open source projects that are using your workflow!)

[Reminder]: # (Submissions are due on December 8th, 2021 (11:59 PM PT or 2 AM ET/6 AM UTC on December 9th).

Have fun!

Top comments (0)