Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto assign datascience issues #14147

Merged
merged 1 commit into from
Sep 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 123 additions & 0 deletions .github/workflows/assignIssue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
name: Assign DS issue to someone
on:
issues:
types: [opened]
jobs:
assignIssue:
name: Assign Issue to Someone
runs-on: ubuntu-latest
if: github.repository == 'microsoft/vscode-python'
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chose to write all of the code in github action rather than creating a seprate .js file with the logic in there. This way its more clear & easier to maintain.

steps:
- name: Created internally
id: internal
env:
ISSUE_OWNER: ${{github.event.issue.owner.login}}
run: |
echo ::set-output name=result::$(node -p -e "['rchiodo', 'greazer', 'joyceerhl', 'DavidKutu', 'claudiaregio', 'IanMatthewHuff', 'DonJayamanne'].filter(item => process.env.ISSUE_OWNER.toLowerCase() === item.toLowerCase()).length > 0 ? 1 : 0")
shell: bash
- name: Should we proceed
id: proceed
env:
ISSUE_LABELS: ${{toJson(github.event.issue.labels)}}
ISSUE_ASSIGNEES: ${{toJson(github.event.issue.assignees)}}
ISSUE_IS_INTERNAL: ${{steps.internal.outputs.result}}
run: |
echo ::set-output name=result::$(node -p -e "process.env.ISSUE_IS_INTERNAL === '0' && JSON.parse(process.env.ISSUE_ASSIGNEES).length === 0 && JSON.parse(process.env.ISSUE_LABELS).filter(item => item.name.indexOf('data science') >= 0).length === 0 ? 1 : 0")
shell: bash
- uses: actions/checkout@v2
if: steps.proceed.outputs.result == 1
- name: Day of week
if: steps.proceed.outputs.result == 1
id: day
run: |
echo ::set-output name=number::$(node -p -e "new Date().getDay()")
shell: bash
- name: Hour of day
if: steps.proceed.outputs.result == 1
id: hour
run: |
echo ::set-output name=hour::$(node -p -e "(new Date().getUTCHours() - 7)%24")
shell: bash
- name: Week Number
if: steps.proceed.outputs.result == 1
id: week
run: |
echo ::set-output name=odd::$(node .github/workflows/week.js)
shell: bash
- name: Print day and week
if: steps.proceed.outputs.result == 1
run: |
echo ${{steps.day.outputs.number}}
echo ${{steps.week.outputs.odd}}
echo ${{steps.hour.outputs.hour}}
shell: bash
- name: Even late friday (David)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could put all of this in to a JS file, again, felt this was easier to main than having to write a JS file & then push data into JS via Env variables & then pull via console output.
Could be difficult to read & figure out.

if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && steps.day.outputs.number == 5 && steps.hour.outputs.hour >= 16
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign DavidKutu
- name: Odd late friday (Joyce)
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && steps.day.outputs.number == 5 && steps.hour.outputs.hour >= 16
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign joyceerhl
- name: Odd weekends (David)
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && (steps.day.outputs.number == 6 || steps.day.outputs.number == 0)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign DavidKutu
- name: Even weekends (Joyce)
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && (steps.day.outputs.number == 6 || steps.day.outputs.number == 0)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign joyceerhl
- name: Odd Monday (David)
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 1 && steps.day.outputs.number == 1 && steps.hour.outputs.hour < 16
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign DavidKutu
- name: Even Monday (Joyce)
if: steps.proceed.outputs.result == 1 && steps.week.outputs.odd == 0 && steps.day.outputs.number == 1 && steps.hour.outputs.hour < 16
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign joyceerhl
- name: Tuesday (Ian)
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)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign IanMatthewHuff
- name: Wednesday (Rich)
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)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign rchiodo
- name: Thursday (Don)
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)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign DonJayamanne
- name: Friday (Claudia)
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)
uses: actions/github@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: assign claudiaregio
29 changes: 29 additions & 0 deletions .github/workflows/week.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* For a given date, get the ISO week number
*
* Based on information at:
*
* http://www.merlyn.demon.co.uk/weekcalc.htm#WNR
*
* Algorithm is to find nearest thursday, it's year
* is the year of the week number. Then get weeks
* between that date and the first day of that year.
*
* Note that dates in one year can be weeks of previous
* or next year, overlap is up to 3 days.
*
* e.g. 2014/12/29 is Monday in week 1 of 2015
* 2012/1/1 is Sunday in week 52 of 2011
*/
function getWeekNumber(d) {
// Copy date so don't modify original
d = new Date(Date.UTC(d.getFullYear(), d.getMonth(), d.getDate()));
// Set to nearest Thursday: current date + 4 - current day number
// Make Sunday's day number 7
d.setUTCDate(d.getUTCDate() + 4 - (d.getUTCDay() || 7));
// Get first day of year
var yearStart = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
// Calculate full weeks to nearest Thursday
return Math.ceil(((d - yearStart) / 86400000 + 1) / 7);
}
// Whether it is an odd or event week.
console.log(getWeekNumber(new Date()) % 2);