-
Notifications
You must be signed in to change notification settings - Fork 15
64 lines (56 loc) · 2.17 KB
/
distribute-grain.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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-*"
# Adds a button to manually trigger a distribution attempt.
# If grain has been distributed for the most recently completed week
# the task will be idempotent.
workflow_dispatch:
jobs:
distribute-grain:
runs-on: ubuntu-latest
env:
NODE_OPTIONS: --max_old_space_size=8192
steps:
- uses: actions/checkout@v2
with:
token: ${{ secrets.ADMIN_TOKEN }}
- 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
- name: Set environment variables
id: details
run: |
echo "COMMIT_TITLE=Scheduled grain distribution for week ending $(date +"%B %dth, %Y")" >> $GITHUB_ENV
description="This commit 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=commit_body::$description"
rm grain_output.txt
- 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