-
Notifications
You must be signed in to change notification settings - Fork 1
100 lines (93 loc) · 3.84 KB
/
vote.yaml
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
name: Vote open
on:
schedule:
# ┌─────────── minute (0 - 59)
# │ ┌────────── hour (0 - 23, UTC)
# │ │ ┌────────── day of the month (1 - 31)
# │ │ │ ┌────────── month (1 - 12 or JAN-DEC)
# │ │ │ │ ┌────────── day of the week (0 - 6 or SUN-SAT)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 14 * * 1'
workflow_dispatch:
branches: [ main ]
env:
COLORS: ("" "26367" "16750848" "65433" "10027263")
AVATAR: https://raw.githubusercontent.com/the-au-forml-lab/plgroup/main/.github/assets/vote.png
USERNAME: "PL Reading Group Paper Vote"
jobs:
vote_options:
if: ${{ vars.PAPER_VOTE_ON == 1 }}
runs-on: ubuntu-latest
strategy:
matrix:
options: [1, 2, 3]
max-parallel: 1
steps:
- uses: actions/checkout@v4
with:
ref: 'main'
- uses: actions/setup-node@v3
with:
node-version: 20
- name: Run chooser
run: |
npm run choose
npm run web
- name: Get selection details
id: vars
run: |
array=${{ env.COLORS }}
echo "subabs=$(echo $(sed -n '3p' ./data/desc.txt) | cut -c 1-1500 | sed 's/[^\x00-\x7F]//g' )" >> $GITHUB_OUTPUT &&
echo "title=$(sed -n '1p' ./data/desc.txt)" >> $GITHUB_OUTPUT &&
echo "mla=$(sed -n '2p' ./data/desc.txt)" >> $GITHUB_OUTPUT &&
echo "abs=$(sed -n '3p' ./data/desc.txt)" >> $GITHUB_OUTPUT &&
echo "doi=$(cat ./data/next.txt)" >> $GITHUB_OUTPUT &&
echo "NOW=$(date +'%d %B')" >> $GITHUB_ENV &&
echo "color=${array[${{ matrix.options }}]}" >> $GITHUB_OUTPUT
- name: Create commit
run: |
git config user.name 'Bot'
git config user.email '[email protected]'
git add -A
git commit -m "Next paper option $NOW"
- name: Create Pull Request
id: paperpr
uses: peter-evans/create-pull-request@v4
with:
add-paths: files/*.txt
labels: paper-vote,next-paper
branch: paper-vote-${{ matrix.options }}
delete-branch: true
title: ${{ steps.vars.outputs.title }}
body: |
This paper was randomly selected as your next reading option.
### ${{ steps.vars.outputs.title }}
${{ steps.vars.outputs.abs }}
> ${{ steps.vars.outputs.mla }}
**Merge this PR to apply selection.**
- name: Post vote option
if: ${{ env.DISCORD_WEBHOOK != '' }}
env:
DISCORD_AVATAR: ${{ env.AVATAR }}
DISCORD_USERNAME: ${{ env.USERNAME }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_EMBEDS: '[{ "color":"${{ steps.vars.outputs.color }}", "title":"${{ steps.vars.outputs.title }}", "description":"${{ steps.vars.outputs.subabs }} [Merge PR ${{ steps.paperpr.outputs.pull-request-number }}](${{ steps.paperpr.outputs.pull-request-url }})" }]'
uses: Ilshidur/action-discord@master
with:
args: "**Vote option ${{ matrix.options }} | ${{ env.NOW }}**"
post_actions:
needs: vote_options
runs-on: ubuntu-latest
steps:
- name: Post vote option
if: ${{ env.DISCORD_WEBHOOK != '' }}
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
DISCORD_AVATAR: ${{ env.AVATAR }}
DISCORD_USERNAME: ${{ env.USERNAME }}
uses: Ilshidur/action-discord@master
with:
args: "**Voting Instructions.**\n- Rank papers using number reactions :one: favorite — :three: least favorite.\n- Set the winner by merging its PR."