forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrift-check.yml
More file actions
59 lines (52 loc) 路 1.96 KB
/
Copy pathdrift-check.yml
File metadata and controls
59 lines (52 loc) 路 1.96 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
name: GitOps Drift Check
on:
schedule:
- cron: "0 6 * * 1"
workflow_dispatch:
permissions:
contents: read
issues: write
jobs:
drift-check:
name: Check Drift
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure kubectl
uses: azure/k8s-set-context@v4
with:
method: kubeconfig
kubeconfig: ${{ secrets.KUBECONFIG }}
- name: Run drift reporter
id: drift
continue-on-error: true
run: |
bash infrastructure/scripts/drift-reporter.sh
- name: Upload drift report
uses: actions/upload-artifact@v4
with:
name: drift-report
path: infrastructure/ci/reports/drift-report-*.json
retention-days: 30
- name: Create issue for critical drifts
if: steps.drift.outcome == 'failure'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const reports = fs.readdirSync('infrastructure/ci/reports/')
.filter(f => f.startsWith('drift-report-'));
if (reports.length === 0) return;
const report = JSON.parse(fs.readFileSync(`infrastructure/ci/reports/${reports[0]}`, 'utf8'));
const critical = report.summary.critical;
const high = report.summary.high;
if (critical > 0 || high > 0) {
const body = `## Drift Report\n\n### Summary\n- Critical drifts: ${critical}\n- High drifts: ${high}\n- Medium drifts: ${report.summary.medium}\n- Low drifts: ${report.summary.low}\n\n### Details\n\`\`\`json\n${JSON.stringify(report.drifts, null, 2)}\n\`\`\``;
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `Drift detected: ${critical + high} critical/high severity drifts`,
body,
labels: ['drift', 'infrastructure'],
});
}