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:
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:
- Setup
- Execute script
- Commit and push
name: Update Polls and Execs
on:
schedule:
- cron: "5 18 * * 1"
jobs:
resources:
name: Update Polls and Execs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
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
with:
file-path: |
src/app/constants/polls.constants.ts
src/app/constants/proposals.constants.ts
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
- The associated app can be found here: https://delegates.makerlabs.one/
- Serves as a supplement to the MakerDAO Delegates program: https://vote.makerdao.com/delegates
- References:
Have fun!
Adam Urban is fullstack engineer, loves serverless and generative art, and is building side projects like weeklyfoo.com, flethy.com and diypunks.xyz in his free time.