-
Notifications
You must be signed in to change notification settings - Fork 2
39 lines (32 loc) · 1.45 KB
/
syncer.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
name: Sync community analyzers
on:
push:
tags:
- v*
env:
SYNC_ENDPOINT: ${{ secrets.SYNC_ENDPOINT }}
DATASYNC_SECRET: ${{ secrets.DATASYNC_SECRET }}
jobs:
sync_analyzers:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.sha }}
- name: Send sync signal
run: |
# Prepare a list of names of all analyzers to sync
# These are all the subdirectories under `analyzers/` of the current repository
# We only want the names of subdir stored as strings in the array
# Expected result: ["infer", "kube-linter"]
analyzer_shortcodes=$(echo -n analyzers/* | sed 's:analyzers/::g; s:/$::' | jq -cRs 'split(" ")')
# Send a sync signal
curl -X POST $SYNC_ENDPOINT -H "Content-Type: application/json" -H "Authorization: Bearer ${DATASYNC_SECRET}" --data-raw '{"query":" mutation($input: TriggerCommunityAnalyzersSyncInput!){\n triggerCommunityAnalyzersSync(input: $input){\n ok\n }\n}","variables":{"input":{"repoRef":'\""$GITHUB_REF_NAME"\"', "analyzerTools":'"$analyzer_shortcodes"'}}}'
# Print a confirmation message
if [ $? -eq 0 ]; then
echo "Sync signal sent for $analyzer_shortcodes."
else
echo "Sync signal failed for $analyzer_shortcodes."
# Exit with a non-zero code to fail this GitHub Action pipeline
exit 1
fi