Vote open #11
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Vote for paper | |
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 * * 5' | |
workflow_dispatch: | |
branches: [ main ] | |
env: | |
COLORS: ("", "26367" "16750848" "65433" "10027263") | |
jobs: | |
vote_option: | |
# if: ${{ vars.PAPER_VOTE_ON == 1 }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
# number of vote options to generate; | |
# The values are not relevant, just the list length. | |
options: [ 1, 2, 3 ] | |
# to generate and post options sequentially | |
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: | | |
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=$COLORS[${{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 | |
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_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_TEST }} | |
DISCORD_EMBEDS: '[{"color":"${{ steps.vars.outputs.color }}", "title":"${{ steps.vars.outputs.title }}", "description":"${{ steps.vars.outputs.subabs }}"}]' | |
uses: Ilshidur/action-discord@master | |
with: | |
args: "${{ env.NOW }} Vote option ${{ matrix.options }} **PR ${{ steps.paperpr.outputs.pull-request-number }}** ${{ steps.paperpr.outputs.pull-request-url }}" |