-
Notifications
You must be signed in to change notification settings - Fork 12
81 lines (79 loc) Β· 2.96 KB
/
blueprints_linter.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
name: Blueprints Linter
on:
pull_request_target:
branches: [main]
jobs:
linting:
name: Blueprints Linter
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Get Changed Files
id: changes
run: |
echo "changed-files=$(git diff --name-only ${{ github.event.pull_request.head.sha }} ${{ github.sha }} | xargs)" >> "$GITHUB_OUTPUT"
- name: Security Check
run: |
if [ ${{ github.event.pull_request.head.repo.full_name }} != ${{ github.repository }} ]; then
if echo ${{ steps.changes.outputs.changed-files }} | grep .scripts &> /dev/null; then
echo "::error::scripts changes is not allowed"
exit 1
elif echo ${{ steps.changes.outputs.changed-files }} | grep .github &> /dev/null; then
echo "::error::workflow changes is not allowed"
exit 1
fi
fi
- name: Check Category
run: ./.scripts/category_checker.sh
- name: Check Vendors
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run marketplace_vendors_checker \
-p /marketplace \
-r ${{ github.event.pull_request.head.repo.full_name }} \
-b "$BRANCH" \
${{ steps.changes.outputs.changed-files }}
- name: Check Devices
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run marketplace_devices_checker \
-p /marketplace \
${{ steps.changes.outputs.changed-files }}
- name: Get Changed Blueprints Paths
id: paths
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run blueprints_collector -p /marketplace ${{ steps.changes.outputs.changed-files }} >> "$GITHUB_OUTPUT"
- name: Run Linter
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
--env ENAPTER_API_TOKEN=${{ secrets.ENAPTER_API_TOKEN }} \
docker.enapter.com/tools/blueprints-linter:v0.4.2 run -g -m ${{ steps.paths.outputs.blueprints-paths }}
- name: Check Blueprint Vendor
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run blueprint_vendor_checker -vp ./.marketplace/vendors/vendors.yml ${{ steps.paths.outputs.blueprints-paths }}
- name: Check Device Blueprint Link
run: |
docker run --rm \
-v "$(pwd)":/marketplace \
-w /marketplace/ \
golang:1.19 go run device_blueprint_link_checker \
-p /marketplace \
${{ steps.paths.outputs.blueprints-paths }}