Skip to content

Distribute Grain

Distribute Grain #133

name: Distribute Grain
on:
# A new Cred interval every Sunday. We'll distribute Grain 5 minutes
# after the new interval
schedule:
- cron: 5 0 * * 0 # 00:05 UTC, 16:05 PST
push:
branches:
# allows us to test this workflow, or manually generate distributions
# PRSs created from grain-trigger-* branches are targeted
# on their immediate base branches, as opposed to master
- "grain-trigger-*"
jobs:
distribute-grain:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max_old_space_size=14000
steps:
- uses: actions/[email protected]
- name: Install Packages 🔧
run: |
yarn --frozen-lockfile
- name: Load Data and Compute Cred 🧮
run: yarn sourcecred go
env:
SOURCECRED_GITHUB_TOKEN: ${{ secrets.SOURCECRED_GITHUB_TOKEN }}
SOURCECRED_DISCORD_TOKEN: ${{ secrets.SOURCECRED_DISCORD_TOKEN }}
- name: Distribute Grain 💸
run: yarn grain > grain_output.txt
- run: cat grain_output.txt
- name: Store all payoutAddresses in lower-case
run: node lower-case-payout-addresses.js
- name: Generate Gnosis CSVs
run: node generate-csv.js
- name: Set environment variables
id: pr_details
run: |
echo "PULL_REQUEST_TITLE=Scheduled grain distribution for week ending $(date +"%B %dth, %Y")" >> $GITHUB_ENV
description="This PR was auto-generated on $(date +%d-%m-%Y) \
to add the latest grain distribution to our instance.
$(cat grain_output.txt)"
description="${description//'%'/'%25'}"
description="${description//$'\n'/'%0A'}"
description="${description//$'\r'/'%0D'}"
echo "::set-output name=pr_body::$description"
rm grain_output.txt
# To create a pull request, use this block:
- name: Create commit and PR for ledger changes
id: pr
uses: peter-evans/[email protected]
with:
branch: generated-ledger
branch-suffix: timestamp
committer: credbot <[email protected]>
# author appears to be overridden when the default github action
# token is used for checkout
author: credbot <[email protected]>
commit-message: update calculated ledger
title: ${{ env.PULL_REQUEST_TITLE }}
body: ${{ steps.pr_details.outputs.pr_body }}
# To commit directly to the main branch, comment the above PR step, and uncomment these steps:
# - name: Commit ledger changes
# run: |
# git config user.name 'credbot'
# git config user.email '[email protected]'
# git add data/ledger.json
# git add config
# git commit --allow-empty -m '${{ env.COMMIT_TITLE }}' -m '${{ steps.details.outputs.commit_body }}'
# - name: Push Ledger
# run: git push