-
Notifications
You must be signed in to change notification settings - Fork 1
133 lines (121 loc) · 4.64 KB
/
create-student-version.yml
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
name: Create student version
on:
workflow_dispatch:
inputs:
semester:
description: "Semester you want to generate, make sure that SEMESTER_WEEKS_XX exists"
default: ""
required: true
# Ensure this workflow has permission to push to the repo
permissions:
contents: write
jobs:
create_student_version:
runs-on: ubuntu-latest
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nbformat nbgrader traitlets
- name: Run script
env:
SEMESTER_WEEKS: ${{ vars[format('SEMESTER_WEEKS_{0}', inputs.semester )] }}
run: python utils/create_student_version.py
- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: student-version
path: release
push_notebooks_to_main:
needs: create_student_version
runs-on: ubuntu-latest
env:
SEMESTER: ${{ github.event.inputs.semester }}
steps:
- name: Check out main
uses: actions/checkout@v4
with:
ref: main
path: main-branch
fetch-depth: 0
- name: Download student-version artifacts
uses: actions/download-artifact@v4
with:
name: student-version
path: student-version
# Overwrite student_versions in main, commit, and push
- name: Overwrite student_versions in main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd main-branch
rm -rf "student_versions/${SEMESTER}"
mkdir -p "student_versions/${SEMESTER}"
ls student_versions/${SEMESTER}
cp -r ../student-version/* "student_versions/${SEMESTER}/"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add "student_versions/${SEMESTER}"
git commit -m "Overwriting notebooks for semester: ${SEMESTER}" --allow-empty
git push origin main
generate_feedback_ids:
needs: create_student_version
runs-on: ubuntu-latest
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
# Download artifacts from the parent workflow
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: student-version
path: notebooks
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nbformat
- name: Run script
env:
SEMESTER_WEEKS: ${{ vars[format('SEMESTER_WEEKS_{0}', inputs.semester )] }}
run: python utils/generate_feedback_ids.py
- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: feedback_json
path: feedback_ids.json
generate_feedback_sql:
needs: generate_feedback_ids
runs-on: ubuntu-latest
steps:
- name: Check out the repository to the runner
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.x"
# Download artifacts from the parent workflow
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: feedback_json
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install nbformat
- name: Run script
run: python utils/generate_sql_statement.py
- name: Publish artifacts
uses: actions/upload-artifact@v4
with:
name: feedback_sql
path: feedback_ids.sql