Skip to content

CWS BTFHub constants sync #492

CWS BTFHub constants sync

CWS BTFHub constants sync #492

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:
ref: no-kmod
repository: DataDog/btfhub-archive
path: dev/dist/archive
- name: Install python
uses: actions/setup-python@v5
with:
python-version: '3.9'
cache: 'pip'
- run: pip install -r requirements.txt
- name: Install go
uses: actions/setup-go@v5
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@v5
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/no-code-change', 'team/agent-security']
});