-
Notifications
You must be signed in to change notification settings - Fork 1
86 lines (75 loc) · 2.78 KB
/
choose.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
80
81
82
83
84
85
86
name: Choose paper
on:
schedule:
# ┌─────────── minute (0 - 59)
# │ ┌────────── hour (0 - 23)
# │ │ ┌────────── 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 ]
pull_request:
branches: [ main ]
types: [ closed ]
jobs:
choose:
if: ${{ vars.PAPER_CHOOSE_ON == 1 && (
github.event_name != 'pull_request' ||
(contains(github.event.pull_request.labels.*.name, 'next-paper') &&
github.event.pull_request.merged == false)
)}}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: 'main'
- uses: actions/setup-node@v3
with:
node-version: 16
- name: Run chooser
run: |
npm run choose
npm run web
- name: Get selection details
id: vars
run: |
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
- name: Create commit
run: |
git config user.name 'Bot'
git config user.email '[email protected]'
git add -A
git commit -m "Next paper $NOW"
- name: Create Pull Request
id: paperpr
uses: peter-evans/create-pull-request@v4
with:
add-paths: files/*.txt
labels: next-paper
branch: next-paper
delete-branch: true
title: ${{ steps.vars.outputs.title }}
body: |
This paper was randomly selected as your next reading.
### ${{ steps.vars.outputs.title }}
${{ steps.vars.outputs.abs }}
> ${{ steps.vars.outputs.mla }}
**Merge this PR to apply selection.**
reviewers: |
${{ fromJSON(vars.REVIEWERS) }}
- name: Enable PR Automerge
if: steps.paperpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v2
with:
token: ${{ secrets.AUTOMERGE_PAT }}
pull-request-number: ${{ steps.paperpr.outputs.pull-request-number }}
merge-method: squash