forked from CAHLR/OATutor
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (121 loc) · 4.58 KB
/
Copy pathincremental-content-update.yml
File metadata and controls
142 lines (121 loc) · 4.58 KB
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
134
135
136
137
138
139
140
141
142
name: Automated Content Update (Partial)
on:
workflow_dispatch:
schedule:
- cron: '0 3 * * *'
- cron: '0 15 * * *'
jobs:
update-content:
runs-on: ubuntu-latest
steps:
- name: Checkout OATutor repository
uses: actions/checkout@v2
with:
ref: 'content-staging'
path: 'content-staging-build'
persist-credentials: true
- name: Clone OATutor-Tooling repository
run: git clone https://github.com/CAHLR/OATutor-Tooling.git /home/runner/work/OATutor-Tooling
- name: Install distutils and build tools
run: |
sudo apt-get update
sudo apt-get install -y build-essential meson ninja-build python3-dev
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.11'
- name: Upgrade pip and install Python dependencies
run: |
pip install --upgrade pip
pip install --prefer-binary -r /home/runner/work/OATutor-Tooling/content_script/requirements.txt
- name: Create credentials JSON file
run: echo "${{ secrets.OATUTOR_JSON_KEY }}" | base64 --decode > /home/runner/work/oatutor-askoski-705644bfdf34.json
- name: Set environment variable for spreadsheet key
run: echo "URL_SPREADSHEET_KEY=${{ secrets.URL_SPREADSHEET_KEY }}" >> $GITHUB_ENV
- name: Prepare for incremental update
run: |
cd content-staging-build/src/content-sources/oatutor
# Rename content-pool back to OpenStax Content for the script
if [ -d "content-pool" ]; then
mv "content-pool" "OpenStax Content"
fi
mkdir -p Content
if [ -f "bkt-params/defaultBKTParams.json" ]; then
cp bkt-params/defaultBKTParams.json bktParams.json
fi
- name: Run content update script
run: |
cd content-staging-build/src/content-sources/oatutor/Content
python3 /home/runner/work/OATutor-Tooling/content_script/final.py online
- name: Move and prepare files
run: |
cd content-staging-build/src/content-sources/oatutor
mv "OpenStax Content" "content-pool"
mkdir -p bkt-params
mv bktParams.json bkt-params/defaultBKTParams.json
cp bkt-params/defaultBKTParams.json bkt-params/experimentalBKTParams.json
- name: Run Node.js preprocessing script
run: |
cd content-staging-build/src/tools
node preprocessProblemPool.js
- name: Configure Git
run: |
cd content-staging-build
git config user.email "generic@example.com"
git config user.name "Generic User"
- name: Commit and push changes
run: |
cd content-staging-build
git add .
if git diff-index --quiet HEAD; then
echo "No changes to commit"
else
git commit -m "Incremental content update"
git push origin content-staging
fi
env:
GITHUB_TOKEN: ${{ secrets.CONTENT_STAGING_PAT }}
- name: Change homepage in package.json
run: |
cd content-staging-build
sed -i 's/place-holder/OATutor-Content-Staging/g' package.json
- name: Run CI install
run: |
cd content-staging-build
npm ci
- name: Run build
run: |
cd content-staging-build
npm run build
env:
REACT_APP_FIREBASE_CONFIG: ${{ secrets.STAGING_FIREBASE_CONFIG }}
CI: false
REACT_APP_BUILD_TYPE: "content-staging"
REACT_APP_MIDDLEWARE_URL: ${{ secrets.STAGING_MIDDLEWARE_URL }}
REACT_APP_COMMIT_HASH: ${{ github.sha }}
REACT_APP_BUILD_TIMESTAMP: ${{ env.build_timestamp }}
- name: Checkout Content Staging
uses: actions/checkout@v3
with:
repository: 'CAHLR/OATutor-Content-Staging'
ref: 'main'
token: ${{ secrets.CONTENT_STAGING_PAT }}
path: 'content-staging-deploy'
- name: Save original git author and git email
run: |
echo "git_email=$(git log --format='%ae' HEAD^!)" >> $GITHUB_ENV
echo "git_name=$(git log --format='%an' HEAD^!)" >> $GITHUB_ENV
- name: Push changes
run: |
cd content-staging-deploy
git rm -rf .
git clean -fxd
rsync -av ../content-staging-build/build/ .
git add .
git config --global user.email "${{ env.git_email || 'oatutor@example.com' }}"
git config --global user.name "${{ env.git_name || 'OATutor' }}"
git diff --cached --quiet --exit-code && echo "no changes to platform, exiting early" && exit 0
git commit -m "deploy commit: CAHLR/OATutor@$GITHUB_SHA"
git push
env:
GITHUB_TOKEN: ${{ secrets.CONTENT_STAGING_PAT }}