Skip to content

Create student version #10

Create student version

Create student version #10

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}"
echo ---
ls "student_versions/${SEMESTER}"
echo ---
ls "../student-version/"
echo ---
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