-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathcheck-if-repository-application-is-installed.yml
More file actions
77 lines (64 loc) · 2.47 KB
/
check-if-repository-application-is-installed.yml
File metadata and controls
77 lines (64 loc) · 2.47 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
name: Check If Repository Application Is Installed
on:
pull_request:
types:
- edited
- opened
- synchronize
jobs:
check-repo-installation:
runs-on: ubuntu-latest
env:
BACKEND_URL: https://api.allocator.tech
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v46
with:
files: 'Allocators/**/*.json'
- name: Check allocator bookkeeping URLs
if: ${{ steps.changed-files.outputs.any_changed == 'true' }}
run: |
failed=0
failures=""
invalid_files=""
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
echo ""
echo "🔍 Processing $file"
repo_url=$(jq -r '.application.allocation_bookkeeping // empty' "$file")
if [[ "$repo_url" == https://github.com/* ]]; then
owner=$(echo "$repo_url" | cut -d'/' -f4)
repo=$(echo "$repo_url" | cut -d'/' -f5)
echo "Found GitHub repo: $owner/$repo"
echo "Checking installation status..."
if curl -f -X GET "${BACKEND_URL}/allocator/check_if_repository_application_is_installed?owner=$owner&repo=$repo"; then
:
else
echo ""
echo "::error file=$file,title=Repository Check Failed::Repository check failed for $owner/$repo"
failures="${failures}\n- $owner/$repo (from $file)"
failed=1
fi
else
echo ""
echo "::warning file=$file,title=Invalid allocation_bookkeeping::Missing or invalid GitHub URL in $file"
invalid_files="${invalid_files}\n- $file"
fi
done
if [[ "$failed" -eq 1 ]]; then
echo ""
echo -e "Repository checks failed:\n$failures"
exit 1
fi
if [[ -n "$invalid_files" ]]; then
echo ""
echo -e "::warning title=Invalid or Missing GitHub URLs::The following files have missing or invalid allocation_bookkeeping GitHub URLs:\n$invalid_files"
exit 1
fi
echo ""
echo "All repository checks passed."
- name: No relevant JSON files found
if: ${{ steps.changed-files.outputs.any_changed == 'false' }}
run: echo "No changed JSON files in Allocators/ — nothing to check."