Skip to content

Vote open

Vote open #58

Workflow file for this run

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 ]
# Discord message options
# see: https://github.com/Ilshidur/action-discord
# see: https://birdie0.github.io/discord-webhooks-guide/discord_webhook.html
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:
# Sequentially generate suggestions, if paper vote is enabled
if: ${{ vars.PAPER_VOTE_ON == 1 }}
runs-on: ubuntu-latest
strategy:
matrix:
options: [1, 2, 3, 4]
max-parallel: 1
steps:
- uses: actions/checkout@v4
with:
ref: 'main'
- uses: actions/setup-node@v4
with:
node-version: 20
- name: 🔮 Choose random paper and update website
run: |
npm run choose
npm run web
- name: 🔎 Lookup selection details
id: vars
# the subabs is abstract posted to Discord.
# It adds some restrictions, of which I know so far:
# - max length (limit 1500 is "safe enough" with link, etc.)
# - characters: sed are to remove special chars, double quotes (post is JSON)
run: |
array=${{ env.COLORS }}
echo "subabs=$(echo $(sed -n '3p' ./data/desc.txt) | cut -c 1-1500 | sed 's/[^\x00-\x7F]//g' | sed 's/\"//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: ✅ Commit paper selection changes
run: |
git config user.name 'Bot'
git config user.email 'the-au-forml-lab@users.noreply.github.com'
git add -A
git commit -m "Next paper option $NOW"
- name: ⬆️ Create a pull request
id: paperpr
uses: peter-evans/create-pull-request@v5
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 to Discord
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 voting instructions
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 — :four: least favorite.\n- Any participant may volunteer to be the **discussion leader** by selecting a paper from the current pool and announcing this to the group (use :coin:). In this case, the vote is void and the paper selected by the discussion leader is selected automatically.\n- Vote concludes by merging the PR of the selected paper."