-
Notifications
You must be signed in to change notification settings - Fork 23
156 lines (139 loc) · 4.73 KB
/
providers.yaml
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: 'Build & Release Providers'
on:
push:
branches: ['main']
paths: ['providers/**']
workflow_dispatch:
inputs:
build_all:
description: 'Force build all providers'
type: boolean
required: false
default: false
skip_publish:
description: 'Skip publishing'
type: boolean
required: false
default: false
env:
BUCKET: releases-us.mondoo.io
SKIP_PROVIDERS: "core"
jobs:
scoping:
name: "Scoping"
runs-on: ubuntu-latest
timeout-minutes: 10
outputs:
providers: ${{ steps.providers.outputs.providers }}
build_list: ${{ steps.providers.outputs.build_list }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect providers
id: providers
run: |
providers=$(find providers -mindepth 1 -maxdepth 1 -type d -exec basename {} \;)
echo "providers=$(echo -n $providers | jq -Rsc 'split(" ")')" >> $GITHUB_OUTPUT
build=""
root=$PWD
for p in $providers; do
skip=0
for s in $SKIP_PROVIDERS; do
if [[ $p == $s ]]; then
skip=1
fi
done
if [[ $skip == 1 ]]; then
echo "$p is on the skip list. Skipping."
continue
fi
cd providers/$p
REPO_VERSION=$(grep Version config/config.go | cut -f2 -d\")
DIST_VERSION=$(curl -s https://releases.mondoo.com/providers/${p}/latest.json | jq -r .version)
printf "PROVIDER $p:\n Local version: $REPO_VERSION\n Remote version: $DIST_VERSION\n"
if [[ $REPO_VERSION != $DIST_VERSION ]]; then
echo " Adding $p to build list"
build="$build $p"
else
echo " Skipping: Provider version unchanged."
fi
cd $root
done
echo "build_list=$(echo -n $build | jq -Rsc 'split(" ")')" >> $GITHUB_OUTPUT
build_all=${{ github.event.inputs.build_all }}
if [[ $build_all == true ]]; then
echo "=== BUILD OF ALL PROVIDERS FORCED ==="
printf '%s\n' "${providers[@]}" | jq -R . | jq -sc . > providers.json
echo "build_list=$(cat providers.json)" >> $GITHUB_OUTPUT
fi
- name: Build List
run: |
echo "=== Providers detected:"
echo ${{ steps.providers.outputs.providers }}
echo "=== Providers select to build:"
echo ${{ steps.providers.outputs.build_list }}
provider-build:
name: "${{ matrix.provider }}"
runs-on: self-hosted
timeout-minutes: 120
needs: scoping
strategy:
fail-fast: false
max-parallel: 2
matrix:
provider: ${{ fromJSON(needs.scoping.outputs.build_list) }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: ">=1.21.0"
cache: false
- name: 'Authenticate to Google Cloud'
uses: 'google-github-actions/auth@v1'
with:
credentials_json: ${{ secrets.GCP_RELEASE_SERVICE_ACCOUNT}}
- name: 'Set up gcloud CLI'
uses: 'google-github-actions/setup-gcloud@v1'
- name: 'Build dependencies'
run: |
make providers/proto
go build -o lr ./providers-sdk/v1/lr/cli/main.go
- name: 'Build Provider'
run: |
rm -rf ./dist
scripts/provider_bundler.sh ${{ matrix.provider }}
- name: 'Publish Provider'
if: ${{ ! inputs.skip_publish }}
run: |
for pkg in $(ls dist | cut -f1,2 -d_ | uniq); do
PROVIDER=$(echo $pkg | cut -f1 -d_)
VERSION=$(echo $pkg | cut -f2 -d_)
echo "Publishing $pkg: $PROVIDER $VERSION"
echo "Publishing $pkg to gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/"
gsutil -m cp -c dist/${pkg}*.xz gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/
gsutil -m cp -c dist/${pkg}_SHA256SUMS gs://${BUCKET}/providers/${PROVIDER}/${VERSION}/
done
- name: 'Save Artifacts'
if: ${{ inputs.skip_publish }}
uses: actions/upload-artifact@v3
with:
name: ${{ matrix.provider }}
path: dist
provider-index:
needs: [provider-build, scoping]
runs-on: ubuntu-latest
if: ${{ ! inputs.skip_publish }}
steps:
- name: Trigger Reindex of releases.mondoo.com
uses: peter-evans/repository-dispatch@v2
with:
token: ${{ secrets.RELEASR_ACTION_TOKEN }}
repository: "mondoohq/releasr"
event-type: reindex
client-payload: '{ }'