Skip to content

Vote open

Vote open #100

Workflow file for this run

name: Vote open
on:
schedule:
- cron: '0 14 * * 3'
workflow_dispatch:
branches: [ main ]
env:
USERNAME: "PL Reading Group Paper Vote"
AVATAR: https://raw.githubusercontent.com/the-au-forml-lab/plgroup/main/.github/assets/vote.png
COLORS: ("" "26367" "16750848" "65433" "10027263")
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
- uses: actions/setup-node@v4
with:
node-version: 20
- name: 🔮 Choose random paper
run: npm run choose
- name: 📝 Update website
run: npm run web
- name: ✅ Commit paper selection changes
run: bash ${PWD}/.github/utils/commit.sh
- name: 🔎 Lookup selection details
id: vars
run: |
array=${{ env.COLORS }}
echo "color=${array[${{ matrix.options }}]}" >> $GITHUB_OUTPUT
echo "body=\"$(bash .github/utils/pr.sh)\"" >> $GITHUB_OUTPUT
echo "title=$(bash .github/utils/title.sh)" >> $GITHUB_OUTPUT
echo "abs=$(bash .github/utils/abs.sh)" >> $GITHUB_OUTPUT
- name: 🔖️ Create a pull request
uses: peter-evans/create-pull-request@v6
id: pr
with:
add-paths: files/*.txt
labels: paper-vote,next-paper
branch: paper-vote-${{ matrix.options }}
title: ${{ steps.vars.outputs.title }}
body: ${{ fromJSON(steps.vars.outputs.body) }}
delete-branch: true
- name: 🗳️ Post vote option to Discord
uses: Ilshidur/action-discord@master
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": "Option ${{ matrix.options }}│ ${{ steps.vars.outputs.title }}",
"url": "${{ steps.pr.outputs.pull-request-url }}",
"description" : "${{ steps.vars.outputs.abs }} [Merge PR ${{ steps.pr.outputs.pull-request-number }}](${{ steps.pr.outputs.pull-request-url }})" }]
post_actions:
needs: vote_options
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: echo "VOTING=\"$(bash .github/utils/voting.sh)\"" >> $GITHUB_ENV
- uses: Ilshidur/action-discord@master
env:
DISCORD_AVATAR: ${{ env.AVATAR }}
DISCORD_USERNAME: ${{ env.USERNAME }}
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
with:
args: ${{ fromJSON(env.VOTING) }}