generated from sourcecred/template-instance
-
Notifications
You must be signed in to change notification settings - Fork 5
71 lines (63 loc) · 2.64 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
65
66
67
68
69
70
71
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
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
- 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