Skip to content

Vote open

Vote open #26

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 ]
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 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_TEST }}
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_TEST }}
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."