Skip to content

Commit 5bf09ad

Browse files
committed
Add github workflows CVE checks
- trigger package test per PR created to merge into 3.0-dev branch Signed-off-by: Aaron Chan <aaron.chun.yew.chan@intel.com>
1 parent bc2a4bf commit 5bf09ad

1 file changed

Lines changed: 116 additions & 0 deletions

File tree

.github/workflows/check-cve.yml

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Copyright (c) Microsoft Corporation.
2+
# Licensed under the MIT License.
3+
4+
# This action rebuilds the package at 3.0-dev (staging) branch
5+
# and uses the CVE security tools to check for any known vulnerabilities.
6+
---
7+
name: Check CVE
8+
9+
on:
10+
pull_request:
11+
branches:
12+
- 3.0-dev
13+
types: [opened, synchronize, reopened, edited]
14+
paths:
15+
- '**.spec'
16+
- 'CVE**.patch'
17+
push:
18+
branches:
19+
- 3.0-dev
20+
paths:
21+
- '**.spec'
22+
- 'CVE**.patch'
23+
permissions:
24+
contents: write
25+
pull-requests: write
26+
27+
env:
28+
GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
29+
GITHUB_PULL_REQUEST_MERGER_REPO: ${{ github.event.pull_request.head.repo.url }}
30+
GITHUB_PULL_REQUEST_MERGER_BRANCH: ${{ github.event.pull_request.head.ref }}
31+
GITHUB_PULL_REQUEST_MERGER_EMAIL: aaron.chun.yew.chan@intel.com
32+
GITHUB_REPO_OWNER: open-edge-platform
33+
GITHUB_REPO_NAME: edge-microvisor-toolkit
34+
35+
jobs:
36+
check:
37+
name: Check CVE in Pull Request
38+
runs-on: trivy
39+
40+
steps:
41+
- name: Checkout code
42+
uses: actions/checkout@v4
43+
with:
44+
persist-credentials: false
45+
ref: ${{ github.event.pull_request.head.sha }}
46+
47+
- name: Setup Python
48+
uses: actions/setup-python@v5
49+
with:
50+
python-version: 3.12
51+
52+
# - name: Get Python dependencies
53+
# run: |
54+
# python3 -m pip install GitPython requests python-dotenv python-rpm-spec pyrpm pyGithub
55+
# pip freeze > requirements.txt
56+
57+
- name: Pull Request and Repository Info
58+
run: |
59+
echo "Requester (GitRepo) : ${{ github.event.pull_request.head.repo.full_name }}"
60+
echo "Requester (Branch) : ${{ github.event.pull_request.head.ref }}"
61+
echo "Current PR (number) : ${{ github.event.pull_request.number }}"
62+
echo "Requester (user) : ${{ github.event.pull_request.user.login }}"
63+
echo "Requester (usermail) : ${{ github.event.pull_request.user.email }}"
64+
65+
- name: Get Package Name and JIRA from PR body
66+
run: |
67+
EMT_PACKAGE_NAME=$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=Package Name:\s)(.*)' || echo "Package Name not found")
68+
echo "EMT_PACKAGE_NAME=$EMT_PACKAGE_NAME" >> $GITHUB_ENV
69+
EMT_JIRA_ITEP=$(echo "${{ github.event.pull_request.body }}" | grep -oP '(?<=JIRA:\s)(\S+)' || echo "JIRA not found")
70+
echo "EMT_JIRA_ITEP=$EMT_JIRA_ITEP" >> $GITHUB_ENV
71+
72+
# - name: assign JIRA label to PR
73+
# uses: actions/github-script@v7
74+
# env:
75+
# GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
76+
# with:
77+
# github-token: ${{ env.GITHUB_TOKEN }}
78+
# base-url: ${{ github.api_url }}
79+
# script: |
80+
# const jiraLabel = '${{ env.EMT_JIRA_ITEP }}';
81+
# if (jiraLabel && jiraLabel !== 'JIRA not found') {
82+
# await github.rest.issues.addLabels({
83+
# owner: '${{ env.GITHUB_REPO_OWNER }}',
84+
# repo: '${{ env.GITHUB_REPO_NAME }}',
85+
# issue_number: '${{ env.GITHUB_PULL_REQUEST_NUMBER }}',
86+
# labels: [jiraLabel],
87+
# });
88+
# console.log(`Added label: ${jiraLabel}`);
89+
# } else {
90+
# console.log('No JIRA label found in PR body.');
91+
# }
92+
93+
# - name: Run Package Tests and CVE Check
94+
# if: contains(github.event.pull_request.head.repo.full_name, 'intel-innersource') || contains(github.event.pull_request.repo.full_name, 'intel-sandbox')
95+
# env:
96+
# BDBA_BASE_URL: ${{ secrets.BDBA_BASE_URL }}
97+
# BDBA_TOKEN: ${{ secrets.BDBA_TOKEN }}
98+
# BDBA_GROUP: ${{ secrets.BDBA_GROUP }}
99+
# CUSTOM_DATA: BuildArch:x86_64,PullRequest:True,MergerRepo:${{ env.GITHUB_PULL_REQUEST_MERGER_REPO }},MergerBranch:${{ env.GITHUB_PULL_REQUEST_MERGER_BRANCH }}
100+
# JENKINS_BUILD_TYPE: BUILD_SPECS
101+
# EMT_PACKAGE_NAME: ${{ env.EMT_PACKAGE_NAME }}
102+
# run: |
103+
# cp ~/.env .env
104+
# cp bdba.py script/jenkins/
105+
# python3 ./script/jenkins/build_packagetest.py \
106+
# --jenkins-joburl ${{ secrets.JENKINS_JOB_URL }} \
107+
# --username ${{ secrets.JENKINS_JOB_USERNAME }} \
108+
# --token ${{ secrets.JENKINS_JOB_TOKEN }} \
109+
# --build-type "${{ env.JENKINS_BUILD_TYPE }}" \
110+
# --package "${{ env.EMT_PACKAGE_NAME }}," \
111+
# --repourl ${{ env.GITHUB_PULL_REQUEST_MERGER_REPO }} \
112+
# --repobranch ${{ env.GITHUB_PULL_REQUEST_MERGER_BRANCH }} \
113+
# --send-email "${{ env.GITHUB_PULL_REQUEST_MERGER_EMAIL }}" \
114+
# --build-container-image True \
115+
# --pull_request_num ${{ env.GITHUB_PULL_REQUEST_NUMBER }}
116+

0 commit comments

Comments
 (0)