diff --git a/.github/workflows/auto_pr_creation_rdke_manifest.yml b/.github/workflows/auto_pr_creation_rdke_manifest.yml new file mode 100644 index 0000000..0ea1022 --- /dev/null +++ b/.github/workflows/auto_pr_creation_rdke_manifest.yml @@ -0,0 +1,60 @@ +name: Update Manifests on Sub-manifest Repo Merge + +on: + workflow_call: + secrets: + RDKCM_RDKE: + required: true + +jobs: + auto_pr_creation_rdke_manifest: + runs-on: ubuntu-latest + if: github.event.pull_request.merged == true + steps: + - name: Checkout build_tools_workflows code + uses: actions/checkout@v4 + with: + repository: rdkcentral/build_tools_workflows + path: 'tools' + ref: develop + token: ${{ secrets.RDKCM_RDKE }} + + - name: Checkout Manifest Repository + uses: actions/checkout@v4 + with: + repository: 'rdkcentral/middleware-manifest-rdke' + path: 'manifest_repo' + ref: develop + token: ${{ secrets.RDKCM_RDKE }} + + - name: Update Git Config + env: + BOT_EMAIL: ${{ vars.RDKM_BOT_EMAIL }} + run: | + cd manifest_repo + git config user.name "bot" + git config user.email "$BOT_EMAIL" + cd .. + + - name: Set up Python + uses: actions/setup-python@v4 + with: + python-version: '3.x' + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + pip install requests PyGithub GitPython + + - name: Run the update script + env: + GITHUB_TOKEN: ${{ secrets.RDKCM_RDKE }} + GITHUB_ORG: 'rdkcentral' + MANIFEST_REPO_PATH: ${{ github.workspace }}/manifest_repo + MANIFEST_REPO_NAME: 'rdkcentral/middleware-manifest-rdke' + PR_NUMBER: ${{ github.event.pull_request.number }} + BASE_BRANCH: ${{ github.event.pull_request.base.ref }} + run: | + cd manifest_repo + python3 ../tools/build_health_check_workflow_scripts/auto_pr_generation_manifest.py + cd .. diff --git a/build_health_check_workflow_scripts/auto_pr_generation_manifest.py b/build_health_check_workflow_scripts/auto_pr_generation_manifest.py index eda6b65..c384eba 100644 --- a/build_health_check_workflow_scripts/auto_pr_generation_manifest.py +++ b/build_health_check_workflow_scripts/auto_pr_generation_manifest.py @@ -146,16 +146,25 @@ def update_xml_files(manifest_repo_path, updates): for xml_file in xml_files: xml_path = os.path.join(manifest_repo_path, xml_file) + print("Checking {}".format(xml_file)) tree = ET.parse(xml_path) root = tree.getroot() file_changed = False for project in root.findall('project'): + print("Checking projects {}".format(project.get('name'))) if project.get('name') in updates and project.get('revision') != updates[project.get('name')]: print("Updating {}: {} from {} to {}".format(xml_file, project.get('name'), project.get('revision'), updates[project.get('name')])) project.set('revision', updates[project.get('name')]) file_changed = True + for submanifest in root.findall('submanifest'): + print("Checking submanifests {}".format(submanifest.get('project'))) + if submanifest.get('project') in updates and submanifest.get('revision') != updates[submanifest.get('project')]: + print("Updating {}: {} from {} to {}".format(xml_file, submanifest.get('project'), submanifest.get('revision'), updates[submanifest.get('project')])) + submanifest.set('revision', updates[submanifest.get('project')]) + file_changed = True + if file_changed: write_xml(root, xml_path) print("Updated {}".format(xml_file))