generated from DSACMS/.github
-
Notifications
You must be signed in to change notification settings - Fork 5
156 lines (126 loc) · 4.94 KB
/
deploy.yml
File metadata and controls
156 lines (126 loc) · 4.94 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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
name: Deploy Manually
on:
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: pages
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- name: Checkout repository with submodules
uses: actions/checkout@v4
with:
submodules: 'recursive'
token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "19.x"
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('frontend/app/package-lock.json') }}
restore-keys: |
npm-
- name: Install dependencies
working-directory: ./frontend/app
run: npm ci --prefer-offline --no-audit
- name: Create required directories
run: mkdir -p frontend/app/site
- name: Run data copy script
run: |
chmod +x ./copy_data_to_submodule.sh
./copy_data_to_submodule.sh
- name: Validate and remove invalid JSON files
run: |
cd frontend/app
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "🔍 JSON Validation Starting..."
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Check if the data directory exists
if [ ! -d "./site/_data" ]; then
echo "❌ Directory ./site/_data does not exist!"
exit 1
fi
echo "📁 Scanning directory: $(pwd)/site/_data"
echo ""
# Count files before validation
total_files=$(find ./site/_data -name "
*.json" -type f | wc -l)
echo "📊 Found $total_files JSON files to validate"
echo ""
# Process each JSON file
invalid_files=()
valid_count=0
invalid_count=0
while IFS= read -r file; do
echo "Checking: $file"
# Check if file exists and is readable
if [ ! -r "$file" ]; then
echo " ⚠️ File not readable, skipping"
continue
fi
# Try to parse the JSON file
if python3 -m json.tool "$file" > /dev/null 2>&1; then
echo " ✅ Valid JSON"
((valid_count++))
else
echo " ❌ INVALID JSON - REMOVING FILE"
echo " 📄 File contents (first 10 lines):"
head -n 10 "$file" | sed 's/^/ /'
# Store the filename for reporting
invalid_files+=("$file")
# Remove the invalid file
rm -f "$file"
# Verify deletion
if [ ! -f "$file" ]; then
echo "
✓ File successfully removed"
else
echo " ✗ WARNING: File still exists after deletion attempt!"
fi
((invalid_count++))
fi
echo ""
done < <(find ./site/_data -name "
*.json" -type f)
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "📊 Validation Complete"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✅ Valid files: $valid_count"
echo "❌ Invalid files: $invalid_count"
if [ $invalid_count -gt 0 ]; then
echo ""
echo "⚠️ The following files were removed:"
printf '%s\n' "${invalid_files[@]}"
fi
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""
# Verify the problematic file is gone
if [ -f "./site/_data/measureauthoringtool/clyde/clyde_data.json" ]; then
echo "❌ ERROR: clyde_data.json still exists!"
echo "Attempting force removal..."
rm -f ./site/_data/measureauthoringtool/clyde/clyde_data.json
else
echo "
✓ Confirmed: clyde_data.json has been removed"
fi
- name: Build project
working-directory: ./frontend/app
run: npm run build
- name: Setup GitHub pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: frontend/app/dist
- name: Deploy to GitHub pages
uses: actions/deploy-pages@v4