Skip to content

Vote open

Vote open #89

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
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: |
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: ✉️ Create embed
run: |
I=${{ matrix.options }}
P=${{ steps.pr.outputs.pull-request-number }}
U="${{ steps.pr.outputs.pull-request-url }}"
T="${{ steps.vars.outputs.title }}"
A="${{ steps.vars.outputs.abs }}"
echo "data=\"$(bash .github/utils/embed.sh $I $P $U \"$T\" \"$A\")\"" >> $GITHUB_OUTPUT
id: embed
- 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: ${{ fromJSON(steps.embed.outputs.data) }}
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) }}