forked from DataDog/datadog-agent
-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (78 loc) · 2.62 KB
/
cws-btfhub-sync.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
name: "CWS BTFHub constants sync"
on:
workflow_dispatch:
schedule:
- cron: '30 4 * * 1-5' # at 4:30 UTC every week-day
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Cleanup runner
run: |
sudo rm -rf /usr/local/lib/android >/dev/null 2>&1
docker rmi $(docker image ls -aq) >/dev/null 2>&1
- name: Checkout datadog-agent repository
uses: actions/checkout@v4
- name: Checkout btfhub-archive repository
uses: actions/checkout@v4
with:
repository: aquasecurity/btfhub-archive
path: dev/dist/archive
- name: Install python
uses: actions/setup-python@v4
with:
python-version: '3.9'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Install go
uses: actions/setup-go@v4
with:
go-version-file: '.go-version'
- name: Install go deps
run: |
inv -e deps
- name: Compute branch name
id: branch-name
run: |
echo "BRANCH_NAME=cws/constants-sync-$(date +%s)" >> $GITHUB_OUTPUT
- name: Sync constants
run: |
inv -e security-agent.generate-btfhub-constants --archive-path=./dev/dist/archive
- uses: stefanzweifel/git-auto-commit-action@v4
id: commit-creator
with:
commit_message: "CWS: sync BTFhub constants"
branch: ${{ steps.branch-name.outputs.BRANCH_NAME }}
create_branch: true
skip_fetch: true
skip_checkout: true
- name: Create Pull Request
uses: actions/github-script@v7
if: steps.commit-creator.outputs.changes_detected == 'true'
with:
script: |
const { repo, owner } = context.repo;
const result = await github.rest.pulls.create({
title: 'CWS: sync BTFHub constants',
owner,
repo,
head: '${{ steps.branch-name.outputs.BRANCH_NAME }}',
base: 'main',
body: [
'### What does this PR do?',
'This PR syncs the BTFHub constants used by CWS',
'_This PR was autogenerated_'
].join('\n')
});
github.rest.issues.update({
owner,
repo,
issue_number: result.data.number,
milestone: 22, // triage
});
github.rest.issues.addLabels({
owner,
repo,
issue_number: result.data.number,
labels: ['changelog/no-changelog', 'qa/skip-qa', 'team/agent-security']
});