-
Notifications
You must be signed in to change notification settings - Fork 78
54 lines (46 loc) · 1.54 KB
/
deploy-challenges.yml
File metadata and controls
54 lines (46 loc) · 1.54 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
name: Deploy Challenges
on:
push:
branches:
- main
paths:
- 'challenges/**'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.9'
- name: Install dependencies
run: |
pip install -r scripts/requirements.txt
- name: Get changed challenges
id: changed
run: |
git diff --name-only HEAD~1 HEAD | grep '^challenges/' > changed_files.txt || true
if [ -s changed_files.txt ]; then
# Extract unique challenge directories (e.g., challenges/easy/1_vector_add -> challenges/easy/1_vector_add)
cat changed_files.txt | sed 's|\(challenges/[^/]*/[^/]*\)/.*|\1|' | sort -u > challenge_paths.txt
if [ -s challenge_paths.txt ]; then
echo "paths<<EOF" >> $GITHUB_OUTPUT
cat challenge_paths.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
fi
- name: Deploy changed challenges
if: steps.changed.outputs.paths != ''
env:
SERVICE_URL: ${{ secrets.LEETGPU_SERVICE_URL }}
LEETGPU_API_KEY: ${{ secrets.LEETGPU_API_KEY }}
run: |
echo "${{ steps.changed.outputs.paths }}" | while read -r path; do
if [ -d "$path" ]; then
echo "Deploying $path"
python scripts/update_challenges.py "$path"
fi
done