-
Notifications
You must be signed in to change notification settings - Fork 0
134 lines (114 loc) · 5.32 KB
/
pr-run.yaml
File metadata and controls
134 lines (114 loc) · 5.32 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
name: Validate & Deploy Plugins
on:
pull_request:
jobs:
validate-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Detect modified plugins
id: detect
run: |
echo "Scanning for modified plugins against origin/main..."
changed_files=$(git diff --name-only origin/main... -- ./plugins)
plugin_paths=$(echo "$changed_files" | grep -oP 'plugins/[^/]+/v[^/]+' | sort -u)
if [ -z "$plugin_paths" ]; then
echo "No plugins were modified in this PR."
echo "plugins_modified=false" >> $GITHUB_OUTPUT
else
echo "Found modified plugin(s):"
echo "$plugin_paths"
echo "plugins_modified=true" >> $GITHUB_OUTPUT
echo "plugin_paths<<EOF" >> $GITHUB_OUTPUT
echo "$plugin_paths" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
fi
- name: Install & Configure SquaredUp CLI
if: steps.detect.outputs.plugins_modified == 'true'
env:
SQUAREDUP_API_KEY: ${{ secrets.SQUAREDUP_API_KEY }}
run: |
echo "Installing SquaredUp CLI..."
npm install -g @squaredup/cli
echo "Configuring SquaredUp CLI with API key..."
squaredup login --apiKey "$SQUAREDUP_API_KEY"
- name: Validate modified plugins
id: validate
if: steps.detect.outputs.plugins_modified == 'true'
run: |
validation_failed=false
while IFS= read -r plugin_path; do
echo "Validating ${plugin_path}..."
result=$(squaredup validate "${plugin_path}" --json) || true
echo "$result" | jq '.'
valid=$(echo "$result" | jq -r '.valid')
echo "$result" | jq -c --arg path "$plugin_path" '. + {plugin_path: $path}' >> /tmp/validation_results.ndjson
if [ "$valid" = "true" ]; then
plugin_name=$(echo "$result" | jq -r '.pluginName')
echo "[PASS] ${plugin_name} passed validation"
echo "$result" | jq '.summary'
else
echo "[FAIL] Validation failed for ${plugin_path}"
echo "$result" | jq -r '.errors[] | " - [\(.file)] \(.message) (path: \(.path | join(".")))"'
validation_failed=true
fi
echo ""
done <<< "${{ steps.detect.outputs.plugin_paths }}"
if [ "$validation_failed" = "true" ]; then
echo "One or more plugins failed validation."
exit 1
fi
- name: Deploy modified plugins
id: deploy
if: steps.detect.outputs.plugins_modified == 'true'
run: |
while IFS= read -r plugin_path; do
echo "Deploying ${plugin_path}..."
squaredup deploy "${plugin_path}" --suffix "${{ github.event.pull_request.number }}" --force
echo "Deployed ${plugin_path} successfully."
echo ""
done <<< "${{ steps.detect.outputs.plugin_paths }}"
- name: Summary
if: always()
run: |
echo "## 🧩 Plugin PR Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ "${{ steps.detect.outputs.plugins_modified }}" != "true" ]; then
echo "ℹ️ No plugins were modified in this PR." >> $GITHUB_STEP_SUMMARY
exit 0
fi
echo "### 📦 Modified Plugins" >> $GITHUB_STEP_SUMMARY
while IFS= read -r plugin_path; do
echo "- \`${plugin_path}\`" >> $GITHUB_STEP_SUMMARY
done <<< "${{ steps.detect.outputs.plugin_paths }}"
echo "" >> $GITHUB_STEP_SUMMARY
echo "### 📋 Results" >> $GITHUB_STEP_SUMMARY
echo "| Step | Status |" >> $GITHUB_STEP_SUMMARY
echo "|------|--------|" >> $GITHUB_STEP_SUMMARY
validate_conclusion="${{ steps.validate.conclusion }}"
deploy_conclusion="${{ steps.deploy.conclusion }}"
[ "$validate_conclusion" = "success" ] && v_status="✅ Passed" || v_status="❌ Failed"
[ "$deploy_conclusion" = "success" ] && d_status="🚀 Deployed" || d_status="⏭️ Skipped"
echo "| Validation | ${v_status} |" >> $GITHUB_STEP_SUMMARY
echo "| Deployment | ${d_status} |" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
if [ -f /tmp/validation_results.ndjson ]; then
echo "### 🔍 Validation Details" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
while IFS= read -r line; do
plugin_path=$(echo "$line" | jq -r '.plugin_path')
valid=$(echo "$line" | jq -r '.valid')
plugin_name=$(echo "$line" | jq -r '.pluginName // .plugin_path')
[ "$valid" = "true" ] && icon="✅" || icon="❌"
echo "<details>" >> $GITHUB_STEP_SUMMARY
echo "<summary>${icon} <code>${plugin_name}</code></summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```json' >> $GITHUB_STEP_SUMMARY
echo "$line" | jq 'del(.plugin_path)' >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
done < /tmp/validation_results.ndjson
fi