-
Notifications
You must be signed in to change notification settings - Fork 1
79 lines (75 loc) · 2.68 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
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) }}