Skip to content

Commit

Permalink
Changes to check script
Browse files Browse the repository at this point in the history
Signed-off-by: Enrique Belarte Luque <[email protected]>
  • Loading branch information
enriquebelarte committed Jan 29, 2025
1 parent 0903e13 commit 5acfb5a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 101 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/check-and-build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Check unbuilt items in matrix and branch

name: Check unbuilt items in matrix, branch and trigger builds
on:
workflow_dispatch:
push:
Expand All @@ -19,6 +18,6 @@ jobs:
python -m pip install --upgrade pip
pip install -r scripts/requirements.txt
- name: Crawl and build from matrix
run: python scripts/check_changes.py
run: python scripts/check-changes.py
env:
TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions scripts/check-changes.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
import json
import subprocess
import requests
import os

# File paths
matrix_json_file = "data/combined_output.json"
argsfile = "argfile.conf"
token = os.getenv("TOKEN")
api = os.getenv("GITHUB_API_URL")
dtk_reg = "quay.io/build-and-sign/pa-driver-toolkit"

if not token:
raise ValueError("GITHUB_TOKEN is missing!")

# Function to update the DRIVER_PUBLISHED field and DRIVER_VERSION file
def update_files(driver_version, kernel_version):
Expand All @@ -27,6 +35,9 @@ def update_files(driver_version, kernel_version):
for line in lines:
if line.startswith("DRIVER_VERSION="):
f.write(f"DRIVER_VERSION={driver_version}\n")
elif line.startswith("DTK_IMAGE="):
dtk_image = f"{dtk_reg}:{kernel_version}"
f.write(f"DTK_IMAGE={dtk_image}\n")
else:
f.write(line)

Expand All @@ -49,6 +60,26 @@ def create_branch_and_pr(driver_version, kernel_version):
# Push branch
subprocess.run(["git", "push", "origin", branch_name], check=True)

# Create the PR for each commit
url = api +"/repos/rh-ecosystem-edge/build-and-sign/pulls"
headers = {
"Accept": "application/vnd.github+json",
"Authorization": f"Bearer {token}",
"X-GitHub-Api-Version": "2022-11-28"
}
data = {
"title": f"Automated build-and-sign PR for {branch_name}",
"body": f"This PR was created automatically by GitHub Actions to trigger a new build and sign of {branch_name}.",
"head": f"{branch_name}",
"base": "main"
}
#print(f"REQUEST: {title} | Headers: {headers} | Data: {data} | URL: {url}")
pr = requests.post(url, headers=headers, json=data)
if pr.status_code == 201:
print(pr.json)
else:
raise SystemExit(f'Error: Got Status {pr.status_code}.')

# Main script
if __name__ == "__main__":
# Load current combined JSON data
Expand Down
98 changes: 0 additions & 98 deletions scripts/check_changes.py

This file was deleted.

0 comments on commit 5acfb5a

Please sign in to comment.