-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (98 loc) · 3.52 KB
/
block-apps.yml
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
name: Block PRs on apps and libs migrated to cloudoperators
on:
pull_request:
types: [opened, synchronize, reopened, edited]
# Default to bash
defaults:
run:
shell: bash
jobs:
changes:
runs-on: [ubuntu-latest]
outputs:
apps: ${{ steps.filters.outputs.apps }}
libs: ${{ steps.filters.outputs.libs }}
app-changes: ${{ steps.app-filters.outputs.changes }}
lib-changes: ${{ steps.lib-filters.outputs.changes }}
steps:
- name: Checkout Pull Request
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
ref: ${{ github.event.pull_request.head.ref }}
- name: Generate app and lib filters
run: |
for folder in apps/*; do
folder_name=$(basename "$folder")
echo "$folder_name: $folder/**" >> temp_app_filters.yaml
done
for folder in libs/*; do
folder_name=$(basename "$folder")
echo "$folder_name: $folder/**" >> temp_lib_filters.yaml
done
- uses: dorny/paths-filter@v3
id: filters
with:
list-files: shell
filters: |
apps: apps/**
libs: libs/**
- uses: dorny/paths-filter@v3
id: app-filters
with:
list-files: shell
filters: temp_app_filters.yaml
- uses: dorny/paths-filter@v3
id: lib-filters
with:
list-files: shell
filters: temp_lib_filters.yaml
- name: Show outputs
run: |
echo "===================="
cat temp_app_filters.yaml
echo "===================="
cat temp_lib_filters.yaml
echo "===================="
echo apps: ${{ steps.filters.outputs.apps}}
echo apps_files: ${{ steps.filters.outputs.apps_files}}
echo app changes: ${{ steps.app-filters.outputs.changes}}
echo libs: ${{ steps.filters.outputs.libs}}
echo libs_files: ${{ steps.filters.outputs.libs_files}}
echo lib changes: ${{ steps.lib-filters.outputs.changes}}
echo "===================="
evaluate-changes:
needs: changes
runs-on: [ubuntu-latest]
env:
APPS: "supernova heureka greenhouse greenhouse-management exampleapp template"
LIBS: "communicator oauth policy-engine messages-provider juno-ui-components url-state-provider url-state-router utils"
steps:
- name: Show inputs
run: |
echo apps: ${{ needs.changes.outputs.apps }}
echo libs: ${{ needs.changes.outputs.libs }}
echo app changes: ${{ needs.changes.outputs.app-changes }}
echo lib changes: ${{ needs.changes.outputs.lib-changes }}
- name: Check if changes belong to restricted apps or libs
id: check-changes
run: |
check_changes() {
local changes=$1
local list=$2
local type=$3
for item in $list; do
if [[ $changes == *"$item"* ]]; then
echo "Not allowed to make changes to specified $type: $item"
exit 1
fi
done
echo "No restricted changes found in $type"
return 0
}
app_changes="${{ needs.changes.outputs.app-changes }}"
lib_changes="${{ needs.changes.outputs.lib-changes }}"
check_changes "$app_changes" "$APPS" "app"
check_changes "$lib_changes" "$LIBS" "lib"
echo "Changes are allowed."