Skip to content

Commit 57dc165

Browse files
authored
Assign issues based on roster (#148)
1 parent 3d7cfb8 commit 57dc165

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

.github/workflows/assignIssue.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: Assign to someone
2+
on:
3+
issues:
4+
types: [opened]
5+
jobs:
6+
assignIssue:
7+
name: Assign Issue to Someone
8+
runs-on: ubuntu-latest
9+
if: github.repository == 'microsoft/vscode-jupyter'
10+
steps:
11+
- name: Should we proceed
12+
id: proceed
13+
env:
14+
ISSUE_ASSIGNEES: ${{toJson(github.event.issue.assignees)}}
15+
run: |
16+
echo ::set-output name=result::$(node -p -e "JSON.parse(process.env.ISSUE_ASSIGNEES).length === 0 ? 1 : 0")
17+
shell: bash
18+
- uses: actions/checkout@v2
19+
if: steps.proceed.outputs.result == 1
20+
- name: Day of week
21+
if: steps.proceed.outputs.result == 1
22+
id: day
23+
run: |
24+
echo ::set-output name=number::$(node -p -e "new Date().getDay()")
25+
shell: bash
26+
- name: Hour of day
27+
if: steps.proceed.outputs.result == 1
28+
id: hour
29+
run: |
30+
echo ::set-output name=hour::$(node -p -e "(new Date().getUTCHours() - 7)%24")
31+
shell: bash
32+
- name: Week Number
33+
if: steps.proceed.outputs.result == 1
34+
id: week
35+
run: |
36+
echo ::set-output name=odd::$(node .github/workflows/week.js)
37+
shell: bash
38+
- name: Print day and week
39+
if: steps.proceed.outputs.result == 1
40+
run: |
41+
echo ${{steps.day.outputs.number}}
42+
echo ${{steps.week.outputs.odd}}
43+
echo ${{steps.hour.outputs.hour}}
44+
shell: bash
45+
- name: Even late friday (David)
46+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && steps.day.outputs.number == 5 && steps.hour.outputs.hour >= 16
47+
uses: actions/[email protected]
48+
env:
49+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
50+
with:
51+
args: assign DavidKutu
52+
- name: Odd late friday (Joyce)
53+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && steps.day.outputs.number == 5 && steps.hour.outputs.hour >= 16
54+
uses: actions/[email protected]
55+
env:
56+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
57+
with:
58+
args: assign joyceerhl
59+
- name: Odd weekends (David)
60+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && (steps.day.outputs.number == 6 || steps.day.outputs.number == 0)
61+
uses: actions/[email protected]
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
args: assign DavidKutu
66+
- name: Even weekends (Joyce)
67+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && (steps.day.outputs.number == 6 || steps.day.outputs.number == 0)
68+
uses: actions/[email protected]
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
args: assign joyceerhl
73+
- name: Odd Monday (David)
74+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && steps.day.outputs.number == 1 && steps.hour.outputs.hour < 16
75+
uses: actions/[email protected]
76+
env:
77+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
78+
with:
79+
args: assign DavidKutu
80+
- name: Even Monday (Joyce)
81+
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && steps.day.outputs.number == 1 && steps.hour.outputs.hour < 16
82+
uses: actions/[email protected]
83+
env:
84+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
85+
with:
86+
args: assign joyceerhl
87+
- name: Tuesday (Ian)
88+
if: steps.proceed.outputs.result == 1 && (steps.day.outputs.number == 1 && steps.hour.outputs.hour >= 16) || (steps.day.outputs.number == 2 && steps.hour.outputs.hour < 16)
89+
uses: actions/[email protected]
90+
env:
91+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92+
with:
93+
args: assign IanMatthewHuff
94+
- name: Wednesday (Rich)
95+
if: steps.proceed.outputs.result == 1 && (steps.day.outputs.number == 2 && steps.hour.outputs.hour >= 16) || (steps.day.outputs.number == 3 && steps.hour.outputs.hour < 16)
96+
uses: actions/[email protected]
97+
env:
98+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
99+
with:
100+
args: assign rchiodo
101+
- name: Thursday (Don)
102+
if: steps.proceed.outputs.result == 1 && (steps.day.outputs.number == 3 && steps.hour.outputs.hour >= 16) || (steps.day.outputs.number == 4 && steps.hour.outputs.hour < 16)
103+
uses: actions/[email protected]
104+
env:
105+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
with:
107+
args: assign DonJayamanne
108+
- name: Friday (Claudia)
109+
if: steps.proceed.outputs.result == 1 && (steps.day.outputs.number == 4 && steps.hour.outputs.hour >= 16) || (steps.day.outputs.number == 5 && steps.hour.outputs.hour < 16)
110+
uses: actions/[email protected]
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
args: assign claudiaregio

.github/workflows/week.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* For a given date, get the ISO week number
2+
*
3+
* Based on information at:
4+
*
5+
* http://www.merlyn.demon.co.uk/weekcalc.htm#WNR
6+
*
7+
* Algorithm is to find nearest thursday, it's year
8+
* is the year of the week number. Then get weeks
9+
* between that date and the first day of that year.
10+
*
11+
* Note that dates in one year can be weeks of previous
12+
* or next year, overlap is up to 3 days.
13+
*
14+
* e.g. 2014/12/29 is Monday in week 1 of 2015
15+
* 2012/1/1 is Sunday in week 52 of 2011
16+
*/
17+
function getWeekNumber(d) {
18+
// Copy date so don't modify original
19+
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
20+
// Set to nearest Thursday: current date + 4 - current day number
21+
// Make Sunday's day number 7
22+
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
23+
// Get first day of year
24+
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
25+
// Calculate full weeks to nearest Thursday
26+
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
27+
}
28+
// Whether it is an odd or event week.
29+
console.log(getWeekNumber(new Date()) % 2);

0 commit comments

Comments
 (0)