From bb40a07fb0bd4e4716595e96cd2cb6eebe59c035 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 29 Mar 2024 17:49:49 +0100 Subject: [PATCH 1/9] feat(workflows): better dependency management --- .../workflows/check_outdated_dependencies.yml | 3 + workflows/check_outdate_deps/Dockerfile | 12 +- workflows/check_outdate_deps/check_deps.py | 208 ++++++++++++++++++ .../check_outdate_deps/check_outdate_deps.sh | 34 --- workflows/check_outdate_deps/open_issue.py | 60 ----- 5 files changed, 218 insertions(+), 99 deletions(-) create mode 100644 workflows/check_outdate_deps/check_deps.py delete mode 100755 workflows/check_outdate_deps/check_outdate_deps.sh delete mode 100755 workflows/check_outdate_deps/open_issue.py diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 5a3c78e7d..1f7ae8021 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -21,4 +21,7 @@ jobs: env: GITHUB_REPOSITORY: ${{ github.repository }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GITHUB_SHA: ${{ secrets.GITHUB_SHA }} REQUIREMENT_FILE: "requirements-workflow.txt" + OPEN_PR: "True" + OPEN_PR_BASE: "main" diff --git a/workflows/check_outdate_deps/Dockerfile b/workflows/check_outdate_deps/Dockerfile index d5b42bd04..d4699c6ed 100644 --- a/workflows/check_outdate_deps/Dockerfile +++ b/workflows/check_outdate_deps/Dockerfile @@ -1,10 +1,12 @@ FROM python:3.12-slim -COPY check_outdate_deps.sh /check_outdate_deps.sh +COPY check_deps.py /check_deps.py +RUN chmod +x /check_deps.py -RUN chmod +x /check_outdate_deps.sh +RUN env -# needed for the open_issue.py -RUN pip3 install requests +RUN pip3 install requests; \ + apt-get update; \ + apt-get install -y --no-install-recommends git -ENTRYPOINT [ "/check_outdate_deps.sh" ] +ENTRYPOINT [ "/check_deps.py" ] diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py new file mode 100644 index 000000000..85db44075 --- /dev/null +++ b/workflows/check_outdate_deps/check_deps.py @@ -0,0 +1,208 @@ +#!/usr/bin/env python3 + +import os +import re +import subprocess +import requests +import json + +TOKEN = str(os.environ.get("GITHUB_TOKEN")) +REPOSITORY = str(os.environ.get("GITHUB_REPOSITORY")) +COMMIT_SHA = str(os.environ.get("GITHUB_SHA")) +REQUIREMENT_FILE = str(os.environ.get("REQUIREMENT_FILE")) +HEADERS = { + "Authorization": f"token {TOKEN}", + "Accept": "application/vnd.github+json" +} +OPEN_PR = os.environ.get("OPEN_PR") +OPEN_PR_BASE = os.environ.get("OPEN_PR_BASE") + + +def create_pull_request(branch, packages_issue): + body = f"Bumps packages in {REQUIREMENT_FILE}." + for package in packages_issue: + body += f"\nCloses #{packages_issue[package]}" + pr_data = { + "title": f"Automation: update outdated packages in {REQUIREMENT_FILE}", + "body": body, + "head": branch, + "base": OPEN_PR_BASE + } + response = requests.get( + f"https://api.github.com/repos/{REPOSITORY}/pulls", + headers=HEADERS) + find_pr = (pr['title'] == pr_data['title'] for pr in response.json()) + if not any(find_pr): + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/pulls", + headers=HEADERS, + data=json.dumps(pr_data)) + if response.status_code == 201: + pr_number = response.json()['number'] + print( + f"INFO: Pull Request -> https://github.com/{REPOSITORY}/pull/{pr_number}") + else: + print(f"ERROR: Failed to create pull request. Status code: { + response.status_code}.") + else: + response = requests.patch( + f"https://api.github.com/repos/{REPOSITORY}/pulls/{find_pr[0]['number']}", + headers=HEADERS, + data=json.dumps(pr_data)) + if response.status_code == 201: + pr_number = response.json()['number'] + print( + f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") + else: + print(f"ERROR: Failed to update the pull requests. Status code: { + response.status_code}.") + + +def update_branch_with_changes(branch, file_to_change): + os.system(f""" +git config --global --add safe.directory /github/workspace +git config --global user.email "dependencybot@linuxlab" +git config --global user.name "DependencyBot" +git fetch --prune +git stash push +git checkout -b {branch} origin/{branch} +git stash pop +git add {file_to_change} +git commit --message=\"Update {file_to_change}\" +git push + """) + + +def find_replace_in_file(file_path, find_str, replace_str): + with open(file_path, 'r') as file: + content = file.read() + content = re.sub(find_str, replace_str, content) + with open(file_path, 'w') as file: + file.write(content) + + +def create_branch_if_not_exists(branch, commit_sha): + response = requests.get( + f"https://api.github.com/repos/{REPOSITORY}/branches/{branch}") + if response.status_code == 404: + refs = {"ref": "refs/heads/" + branch, "sha": commit_sha} + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/git/refs", + headers=HEADERS, data=json.dumps(refs)) + if response.status_code == 201: + print( + f"INFO: Branch created -> https://github.com/{REPOSITORY}/tree/{branch}") + else: + print("ERROR: branch not created") + else: + print( + f"INFO: Branch -> https://github.com/{REPOSITORY}/tree/{branch}") + + +def open_issue_for_package(package, current_version, latest_version): + issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: { + package}=={current_version} -> {latest_version}" + query = f"repo:{REPOSITORY} type:issue in:title \"{issue_title}\"" + response = requests.get( + "https://api.github.com/search/issues", params={"q": query}) + data = response.json() + if data["total_count"] > 0: + issue_number = data['items'][0]['number'] + print( + f"INFO: Issue -> https://github.com/{REPOSITORY}/issues/{issue_number}") + return issue_number + else: + issue_description = f""" +The package {package} is outdated in {REQUIREMENT_FILE}. + +The latest version is {latest_version}. Please update the package to the latest version. + +Check the package [here](https://pypi.org/project/{package}/{latest_version}/) for more information. + """ + issue = {"title": issue_title, + "body": issue_description, + "labels": ["automation"]} + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/issues", + headers=HEADERS, + data=json.dumps(issue)) + if response.status_code == 201: + issue_number = response.json()['number'] + print( + f"INFO: Issue created -> https://github.com/{REPOSITORY}/issues/{issue_number}") + return issue_number + else: + print(f"ERROR: Failed to create issue. Status code: { + response.status_code}.") + return -1 + + +def build_packages_dict_from_file(requirement_file): + print("-------------") + print("INFO: create dict from file") + packages = {} + with open(REQUIREMENT_FILE, 'r') as file: + lines = file.readlines() + for line in lines: + regex_pattern = re.compile( + "([a-zA-Z0-9-]+)==([0-9]+\.[0-9]+\.[0-9]+)") + matches = regex_pattern.findall(line) + if len(matches) > 0: + package_name = str(matches[0][0]) + package_version = str(matches[0][1]) + packages[package_name] = package_version + return packages + + +def build_packages_dict_from_output(output): + print("-------------") + print("INFO: create dict from output") + packages = {} + lines = output.splitlines(output) + for line in lines: + regex_pattern = re.compile( + "([a-zA-Z0-9-]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([a-zA-Z]+)") + matches = regex_pattern.findall(line) + if len(matches) > 0: + package_name = str(matches[0][0]) + package_version = str(matches[0][2]) + packages[package_name] = package_version + return packages + + +if __name__ == '__main__': + os.system(f"pip3 install -r {REQUIREMENT_FILE}") + raw_output_outdated = subprocess.run( + ['pip3', 'list', '--outdated'], + stdout=subprocess.PIPE) + current_packages = build_packages_dict_from_file(REQUIREMENT_FILE) + latest_packages = build_packages_dict_from_output( + raw_output_outdated.stdout.decode('utf-8')) + packages_issue = {} + if OPEN_PR == "True": + branch = "automation/dependencies_update" + create_branch_if_not_exists(branch, COMMIT_SHA) + for package in current_packages.keys(): + if package in latest_packages: + current_version = current_packages[package] + latest_version = latest_packages[package] + packages_issue[package] = open_issue_for_package( + package, current_version, latest_version) + + if OPEN_PR == "True": + line_current = f"{package}==[0-9]+\.[0-9]+\.[0-9]+" + line_latest = f"{package}=={latest_version}" + find_replace_in_file(REQUIREMENT_FILE, + line_current, + line_latest) + print(f""" + ---------------- + package: {package} + current: {current_version} + latest: {latest_version} + issue: {packages_issue[package]} + ---------------- + """) + if OPEN_PR == "True": + update_branch_with_changes(branch, REQUIREMENT_FILE) + create_pull_request(branch, packages_issue) diff --git a/workflows/check_outdate_deps/check_outdate_deps.sh b/workflows/check_outdate_deps/check_outdate_deps.sh deleted file mode 100755 index eed1198b1..000000000 --- a/workflows/check_outdate_deps/check_outdate_deps.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env bash - -pip3 install -r "$REQUIREMENT_FILE" -input=$(pip3 list --outdated) - -compare_versions() { - local version1=$1 - local version2=$2 - local IFS='.' - - read -ra version1_splitted <<< "$version1" - read -ra version2_splitted <<< "$version2" - - for ((i=0;i<${#version1_splitted[@]};i++)); do - delta=$(( version1_splitted[i] - version2_splitted[i] )) - if (( delta != 0 )); then - echo $delta - return - fi - done - echo 0 -} - -while read -r line; do - if [[ $line =~ ^([a-zA-Z0-9-]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([a-zA-Z]+) ]]; then - package="${BASH_REMATCH[1]}" - version="${BASH_REMATCH[2]}" - latest="${BASH_REMATCH[3]}" - - if [ "$(compare_versions "$version" "$latest")" -lt 0 ]; then - ./workflows/check_outdate_deps/open_issue.py "$package" "$version" "$latest" - fi - fi -done <<< "$input" diff --git a/workflows/check_outdate_deps/open_issue.py b/workflows/check_outdate_deps/open_issue.py deleted file mode 100755 index 39689ef6f..000000000 --- a/workflows/check_outdate_deps/open_issue.py +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -import argparse -import requests -import os -import json - - -def get_description(requirement_file, package, latest): - return f"""The package {package} is outdated in {requirement_file}. The latest version is {latest}. Please update the package to the latest version. - -Check the package [here](https://pypi.org/project/{package}/{latest}/) for more information. -""" - - -def get_title(requirement_file, package_name, current_version, latest_version): - return f"Dependency outdated in {requirement_file}: {package_name}:{current_version} -> {latest_version}" - - -if __name__ == '__main__': - # Arguments parsing - parser = argparse.ArgumentParser(description="Open issue with the correct argument") - parser.add_argument("package", type=str, help='The name of the package') - parser.add_argument("version", type=str, help='The current version of the package') - parser.add_argument("latest", type=str, help='The latest version of the package') - args = parser.parse_args() - - # Environment variable - repo = os.environ.get("GITHUB_REPOSITORY") - requirement_file = str(os.environ.get("REQUIREMENT_FILE")) - - # Define the title - issue_title = get_title(requirement_file, args.package, args.version, args.latest) - - # The double quote on the issue_title is necessary to avoid duplicate issues - query = f"repo:{repo} type:issue in:title \"{issue_title}\"" - - # Send the query - response = requests.get("https://api.github.com/search/issues", params={"q": query}) - data = response.json() - - # There is this error that we somehow try to avoid - # {'message': "API rate limit exceeded for 93.45.31.205. (But here's the good news: Authenticated requests get a higher rate limit. Check - # out the documentation for more details.)", 'documentation_url': 'https://docs.github.com/rest/overview/resources-in-the-rest-api#rat - # e-limiting'} - if data["total_count"] > 0: - print("There is already an issue with this title!") - else: - issue_description = get_description(requirement_file, args.package, args.latest) - token = os.environ.get("GITHUB_TOKEN") - issue = {"title": issue_title, "body": issue_description} - headers = {"Authorization": f"token {token}"} - - response = requests.post(f"https://api.github.com/repos/{repo}/issues", headers=headers, data=json.dumps(issue)) - - # Check the response - if response.status_code == 201: - print("Issue created successfully.") - else: - print(f"Failed to create issue. Status code: {response.status_code}.") From 18fb572cd57b8981747e2be300209fec6e55b50e Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 29 Mar 2024 18:12:27 +0100 Subject: [PATCH 2/9] fix(workflows): change the base branch --- .../workflows/check_outdated_dependencies.yml | 2 +- workflows/check_outdate_deps/check_deps.py | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 1f7ae8021..54b235301 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -24,4 +24,4 @@ jobs: GITHUB_SHA: ${{ secrets.GITHUB_SHA }} REQUIREMENT_FILE: "requirements-workflow.txt" OPEN_PR: "True" - OPEN_PR_BASE: "main" + OPEN_PR_BASE: "dev" diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py index 85db44075..59dab1eef 100644 --- a/workflows/check_outdate_deps/check_deps.py +++ b/workflows/check_outdate_deps/check_deps.py @@ -16,6 +16,7 @@ } OPEN_PR = os.environ.get("OPEN_PR") OPEN_PR_BASE = os.environ.get("OPEN_PR_BASE") +BRANCH = "automation/dependencies_update" def create_pull_request(branch, packages_issue): @@ -43,10 +44,11 @@ def create_pull_request(branch, packages_issue): f"INFO: Pull Request -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: print(f"ERROR: Failed to create pull request. Status code: { - response.status_code}.") + response.status_code}.") else: response = requests.patch( - f"https://api.github.com/repos/{REPOSITORY}/pulls/{find_pr[0]['number']}", + f"https://api.github.com/repos/{ + REPOSITORY}/pulls/{find_pr[0]['number']}", headers=HEADERS, data=json.dumps(pr_data)) if response.status_code == 201: @@ -55,7 +57,7 @@ def create_pull_request(branch, packages_issue): f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: print(f"ERROR: Failed to update the pull requests. Status code: { - response.status_code}.") + response.status_code}.") def update_branch_with_changes(branch, file_to_change): @@ -180,14 +182,15 @@ def build_packages_dict_from_output(output): raw_output_outdated.stdout.decode('utf-8')) packages_issue = {} if OPEN_PR == "True": - branch = "automation/dependencies_update" - create_branch_if_not_exists(branch, COMMIT_SHA) + create_branch_if_not_exists(BRANCH, COMMIT_SHA) for package in current_packages.keys(): if package in latest_packages: current_version = current_packages[package] latest_version = latest_packages[package] packages_issue[package] = open_issue_for_package( package, current_version, latest_version) + # TODO: check if there is already a issue for this package with + # old dependency version if OPEN_PR == "True": line_current = f"{package}==[0-9]+\.[0-9]+\.[0-9]+" @@ -204,5 +207,5 @@ def build_packages_dict_from_output(output): ---------------- """) if OPEN_PR == "True": - update_branch_with_changes(branch, REQUIREMENT_FILE) - create_pull_request(branch, packages_issue) + update_branch_with_changes(BRANCH, REQUIREMENT_FILE) + create_pull_request(BRANCH, packages_issue) From 77484e68333dc20e07e4670e5287f1c7cf9c9ffe Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:14:13 +0200 Subject: [PATCH 3/9] feat(workflows): automatic issue close when outdated --- .../workflows/check_outdated_dependencies.yml | 1 + workflows/check_outdate_deps/check_deps.py | 115 +++++++++++------- 2 files changed, 72 insertions(+), 44 deletions(-) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 54b235301..28e94533c 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -25,3 +25,4 @@ jobs: REQUIREMENT_FILE: "requirements-workflow.txt" OPEN_PR: "True" OPEN_PR_BASE: "dev" + ISSUE_AUTOCLOSE: "True" diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py index 59dab1eef..fdfa01761 100644 --- a/workflows/check_outdate_deps/check_deps.py +++ b/workflows/check_outdate_deps/check_deps.py @@ -16,8 +16,44 @@ } OPEN_PR = os.environ.get("OPEN_PR") OPEN_PR_BASE = os.environ.get("OPEN_PR_BASE") +ISSUE_AUTOCLOSE = os.environ.get("ISSUE_AUTOCLOSE") BRANCH = "automation/dependencies_update" +def close_issue_if_old(package, current_version, latest_version, new_issue_number): + issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" + query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" + response = requests.get( + "https://api.github.com/search/issues", params={"q": query}) + data = response.json() + issue_title_latest = f"Dependency outdated in {REQUIREMENT_FILE}: { + package}=={current_version} -> {latest_version}" + for issue in data['items']: + if issue['title'] != issue_title_latest: + comment = f""" +A new version of the package is out, check out the new issue #{new_issue_number}. + """ + comment_data = { + "body": comment + } + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/issues/{issue['number']}/comments", + headers=HEADERS, + data=json.dumps(comment_data)) + if response.status_code == 201: + print(f"INFO: Comment done in -> https://github.com/{REPOSITORY}/issues/{issue['number']}") + else: + print(f"ERROR: Failed to create comment. Status code: {response.status_code}.") + issue_data = { + "state": "closed" + } + response = requests.patch( + f"https://api.github.com/repos/{REPOSITORY}/issues/{issue['number']}", + headers=HEADERS, + data=json.dumps(issue_data)) + if response.status_code == 200: + print(f"INFO: Issue closed -> https://github.com/{REPOSITORY}/issues/{issue['number']}") + else: + print(f"ERROR: Failed to close the issue. Status code: {response.status_code}.") def create_pull_request(branch, packages_issue): body = f"Bumps packages in {REQUIREMENT_FILE}." @@ -32,7 +68,7 @@ def create_pull_request(branch, packages_issue): response = requests.get( f"https://api.github.com/repos/{REPOSITORY}/pulls", headers=HEADERS) - find_pr = (pr['title'] == pr_data['title'] for pr in response.json()) + find_pr = list(pr['number'] for pr in response.json() if pr['title'] == pr_data['title']) if not any(find_pr): response = requests.post( f"https://api.github.com/repos/{REPOSITORY}/pulls", @@ -40,24 +76,19 @@ def create_pull_request(branch, packages_issue): data=json.dumps(pr_data)) if response.status_code == 201: pr_number = response.json()['number'] - print( - f"INFO: Pull Request -> https://github.com/{REPOSITORY}/pull/{pr_number}") + print(f"INFO: Pull Request open -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: - print(f"ERROR: Failed to create pull request. Status code: { - response.status_code}.") + print(f"ERROR: Failed to create pull request. Status code: {response.status_code}.") else: response = requests.patch( - f"https://api.github.com/repos/{ - REPOSITORY}/pulls/{find_pr[0]['number']}", + f"https://api.github.com/repos/{REPOSITORY}/pulls/{find_pr[0]}", headers=HEADERS, data=json.dumps(pr_data)) - if response.status_code == 201: + if response.status_code == 200: pr_number = response.json()['number'] - print( - f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") + print(f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: - print(f"ERROR: Failed to update the pull requests. Status code: { - response.status_code}.") + print(f"ERROR: Failed to update the pull requests. Status code: {response.status_code}.") def update_branch_with_changes(branch, file_to_change): @@ -84,34 +115,31 @@ def find_replace_in_file(file_path, find_str, replace_str): def create_branch_if_not_exists(branch, commit_sha): - response = requests.get( - f"https://api.github.com/repos/{REPOSITORY}/branches/{branch}") + response = requests.get(f"https://api.github.com/repos/{REPOSITORY}/branches/{branch}") if response.status_code == 404: refs = {"ref": "refs/heads/" + branch, "sha": commit_sha} response = requests.post( f"https://api.github.com/repos/{REPOSITORY}/git/refs", - headers=HEADERS, data=json.dumps(refs)) + headers=HEADERS, + data=json.dumps(refs)) if response.status_code == 201: - print( - f"INFO: Branch created -> https://github.com/{REPOSITORY}/tree/{branch}") + print(f"INFO: Branch created -> https://github.com/{REPOSITORY}/tree/{branch}") else: print("ERROR: branch not created") else: - print( - f"INFO: Branch -> https://github.com/{REPOSITORY}/tree/{branch}") + print(f"INFO: Branch -> https://github.com/{REPOSITORY}/tree/{branch}") def open_issue_for_package(package, current_version, latest_version): issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: { package}=={current_version} -> {latest_version}" - query = f"repo:{REPOSITORY} type:issue in:title \"{issue_title}\"" + query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" response = requests.get( "https://api.github.com/search/issues", params={"q": query}) data = response.json() if data["total_count"] > 0: issue_number = data['items'][0]['number'] - print( - f"INFO: Issue -> https://github.com/{REPOSITORY}/issues/{issue_number}") + print(f"INFO: Issue -> https://github.com/{REPOSITORY}/issues/{issue_number}") return issue_number else: issue_description = f""" @@ -130,18 +158,15 @@ def open_issue_for_package(package, current_version, latest_version): data=json.dumps(issue)) if response.status_code == 201: issue_number = response.json()['number'] - print( - f"INFO: Issue created -> https://github.com/{REPOSITORY}/issues/{issue_number}") + print(f"INFO: Issue created -> https://github.com/{REPOSITORY}/issues/{issue_number}") return issue_number else: - print(f"ERROR: Failed to create issue. Status code: { - response.status_code}.") + print(f"ERROR: Failed to create issue. Status code: {response.status_code}.") return -1 -def build_packages_dict_from_file(requirement_file): - print("-------------") - print("INFO: create dict from file") +def build_packages_dict_from_file(): + print("INFO: create dictionary from file") packages = {} with open(REQUIREMENT_FILE, 'r') as file: lines = file.readlines() @@ -157,8 +182,7 @@ def build_packages_dict_from_file(requirement_file): def build_packages_dict_from_output(output): - print("-------------") - print("INFO: create dict from output") + print("INFO: create dictionary from output") packages = {} lines = output.splitlines(output) for line in lines: @@ -173,24 +197,31 @@ def build_packages_dict_from_output(output): if __name__ == '__main__': + print("##### Collect datas #####") os.system(f"pip3 install -r {REQUIREMENT_FILE}") raw_output_outdated = subprocess.run( ['pip3', 'list', '--outdated'], stdout=subprocess.PIPE) - current_packages = build_packages_dict_from_file(REQUIREMENT_FILE) - latest_packages = build_packages_dict_from_output( - raw_output_outdated.stdout.decode('utf-8')) + current_packages = build_packages_dict_from_file() + latest_packages = build_packages_dict_from_output(raw_output_outdated.stdout.decode('utf-8')) + print("##### Create datas #####") packages_issue = {} if OPEN_PR == "True": create_branch_if_not_exists(BRANCH, COMMIT_SHA) + print("##### Run checks #####") for package in current_packages.keys(): + print(f"----- Check {package} -----") if package in latest_packages: current_version = current_packages[package] latest_version = latest_packages[package] + print(f""" +INFO: current version {current_version} +INFO: latest version {latest_version}""") packages_issue[package] = open_issue_for_package( package, current_version, latest_version) - # TODO: check if there is already a issue for this package with - # old dependency version + + if ISSUE_AUTOCLOSE == "True": + close_issue_if_old(package, current_version, latest_version, packages_issue[package]) if OPEN_PR == "True": line_current = f"{package}==[0-9]+\.[0-9]+\.[0-9]+" @@ -198,14 +229,10 @@ def build_packages_dict_from_output(output): find_replace_in_file(REQUIREMENT_FILE, line_current, line_latest) - print(f""" - ---------------- - package: {package} - current: {current_version} - latest: {latest_version} - issue: {packages_issue[package]} - ---------------- - """) + print("----------------") + else: + print(f"INFO: Skipping {package} => not in scope of {REQUIREMENT_FILE}") + print("----------------") if OPEN_PR == "True": update_branch_with_changes(BRANCH, REQUIREMENT_FILE) create_pull_request(BRANCH, packages_issue) From 62d77fbd94ccb35bebdc3e61fac3e2c35e23ac7c Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Tue, 2 Apr 2024 18:17:13 +0200 Subject: [PATCH 4/9] fix(workflows): remove env output from action --- workflows/check_outdate_deps/Dockerfile | 2 -- 1 file changed, 2 deletions(-) diff --git a/workflows/check_outdate_deps/Dockerfile b/workflows/check_outdate_deps/Dockerfile index d4699c6ed..e79189f2b 100644 --- a/workflows/check_outdate_deps/Dockerfile +++ b/workflows/check_outdate_deps/Dockerfile @@ -3,8 +3,6 @@ FROM python:3.12-slim COPY check_deps.py /check_deps.py RUN chmod +x /check_deps.py -RUN env - RUN pip3 install requests; \ apt-get update; \ apt-get install -y --no-install-recommends git From 424e9bc8880afe135a505f60080ed8fc9c88ecf6 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Thu, 4 Apr 2024 20:20:01 +0200 Subject: [PATCH 5/9] fix(workflows): issue update itself not close and open new --- workflows/check_outdate_deps/check_deps.py | 268 ++++++++++++--------- 1 file changed, 148 insertions(+), 120 deletions(-) diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py index fdfa01761..284825fd4 100644 --- a/workflows/check_outdate_deps/check_deps.py +++ b/workflows/check_outdate_deps/check_deps.py @@ -19,69 +19,136 @@ ISSUE_AUTOCLOSE = os.environ.get("ISSUE_AUTOCLOSE") BRANCH = "automation/dependencies_update" -def close_issue_if_old(package, current_version, latest_version, new_issue_number): - issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" - query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" + +def __build_packages_dict_from_file(): + print("INFO: create dictionary from file") + packages = {} + with open(REQUIREMENT_FILE, 'r') as file: + lines = file.readlines() + for line in lines: + regex_pattern = re.compile( + "([a-zA-Z0-9-]+)==([0-9]+\.[0-9]+\.[0-9]+)") + matches = regex_pattern.findall(line) + if len(matches) > 0: + package_name = str(matches[0][0]) + package_version = str(matches[0][1]) + packages[package_name] = package_version + return packages + + +def __build_packages_dict_from_output(output): + print("INFO: create dictionary from output") + packages = {} + lines = output.splitlines(output) + for line in lines: + regex_pattern = re.compile( + "([a-zA-Z0-9-]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([a-zA-Z]+)") + matches = regex_pattern.findall(line) + if len(matches) > 0: + package_name = str(matches[0][0]) + package_version = str(matches[0][2]) + packages[package_name] = package_version + return packages + + +def __create_branch(branch, branch_data): + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/git/refs", + headers=HEADERS, + data=json.dumps(branch_data)) + if response.status_code == 201: + print(f"INFO: Branch created -> https://github.com/{REPOSITORY}/tree/{branch}") + else: + print(f"ERROR: Failed to create branch. Status code: {response.status_code}.") + + +def __search_issues(query): response = requests.get( "https://api.github.com/search/issues", params={"q": query}) - data = response.json() - issue_title_latest = f"Dependency outdated in {REQUIREMENT_FILE}: { - package}=={current_version} -> {latest_version}" - for issue in data['items']: + return response.json()['items'] + + +def __create_issue(issue_data): + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/issues", + headers=HEADERS, + data=json.dumps(issue_data)) + if response.status_code == 201: + issue_number = response.json()['number'] + print(f"INFO: Issue created -> https://github.com/{REPOSITORY}/issues/{issue_number}") + return issue_number + else: + print(f"ERROR: Failed to create issue. Status code: {response.status_code}.") + return -1 + + +def __update_issue(issue_number, issue): + response = requests.patch( + f"https://api.github.com/repos/{REPOSITORY}/issues/{issue_number}", + headers=HEADERS, + data=json.dumps(issue)) + if response.status_code == 200: + print(f"INFO: Issue updated -> https://github.com/{REPOSITORY}/issues/{issue_number}") + else: + print(f"ERROR: Failed to update the issue. Status code: {response.status_code}.") + + +def __comment_issue(issue_number, comment): + comment_data = { + "body": comment + } + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/issues/{issue_number}/comments", + headers=HEADERS, + data=json.dumps(comment_data)) + if response.status_code == 201: + print(f"INFO: Comment done in -> https://github.com/{REPOSITORY}/issues/{issue_number}") + else: + print(f"ERROR: Failed to create comment. Status code: {response.status_code}.") + + +def __check_if_issue_already_exists(package, current_version, latest_version): + issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" + query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" + items = __search_issues(query) + issue_title_latest = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version} -> {latest_version}" + for issue in items: if issue['title'] != issue_title_latest: - comment = f""" -A new version of the package is out, check out the new issue #{new_issue_number}. - """ - comment_data = { - "body": comment - } - response = requests.post( - f"https://api.github.com/repos/{REPOSITORY}/issues/{issue['number']}/comments", - headers=HEADERS, - data=json.dumps(comment_data)) - if response.status_code == 201: - print(f"INFO: Comment done in -> https://github.com/{REPOSITORY}/issues/{issue['number']}") - else: - print(f"ERROR: Failed to create comment. Status code: {response.status_code}.") - issue_data = { - "state": "closed" - } - response = requests.patch( - f"https://api.github.com/repos/{REPOSITORY}/issues/{issue['number']}", - headers=HEADERS, - data=json.dumps(issue_data)) - if response.status_code == 200: - print(f"INFO: Issue closed -> https://github.com/{REPOSITORY}/issues/{issue['number']}") - else: - print(f"ERROR: Failed to close the issue. Status code: {response.status_code}.") + return issue['number'], issue['title'], issue['body'] + return 0, "", "" + + +def __create_pull_request(pr_data): + response = requests.post( + f"https://api.github.com/repos/{REPOSITORY}/pulls", + headers=HEADERS, + data=json.dumps(pr_data)) + if response.status_code == 201: + pr_number = response.json()['number'] + print(f"INFO: Pull Request open -> https://github.com/{REPOSITORY}/pull/{pr_number}") + return pr_number + else: + print(f"ERROR: Failed to create pull request. Status code: {response.status_code}.") + return -1 def create_pull_request(branch, packages_issue): body = f"Bumps packages in {REQUIREMENT_FILE}." for package in packages_issue: body += f"\nCloses #{packages_issue[package]}" + title= f"Automation: update outdated packages in {REQUIREMENT_FILE}" pr_data = { - "title": f"Automation: update outdated packages in {REQUIREMENT_FILE}", + "title": title, "body": body, "head": branch, "base": OPEN_PR_BASE } - response = requests.get( - f"https://api.github.com/repos/{REPOSITORY}/pulls", - headers=HEADERS) - find_pr = list(pr['number'] for pr in response.json() if pr['title'] == pr_data['title']) - if not any(find_pr): - response = requests.post( - f"https://api.github.com/repos/{REPOSITORY}/pulls", - headers=HEADERS, - data=json.dumps(pr_data)) - if response.status_code == 201: - pr_number = response.json()['number'] - print(f"INFO: Pull Request open -> https://github.com/{REPOSITORY}/pull/{pr_number}") - else: - print(f"ERROR: Failed to create pull request. Status code: {response.status_code}.") - else: + query = f"{title} repo:{REPOSITORY} type:pull-request in:title" + items = __search_issues(query) + if not any(items): + __create_pull_request(pr_data) + elif len(items) == 1: response = requests.patch( - f"https://api.github.com/repos/{REPOSITORY}/pulls/{find_pr[0]}", + f"https://api.github.com/repos/{REPOSITORY}/pulls/{items[0]}", headers=HEADERS, data=json.dumps(pr_data)) if response.status_code == 200: @@ -89,6 +156,8 @@ def create_pull_request(branch, packages_issue): print(f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: print(f"ERROR: Failed to update the pull requests. Status code: {response.status_code}.") + else: + print(f"ERROR: More than 1 pull-request with the same title are found! I can't update.") def update_branch_with_changes(branch, file_to_change): @@ -117,83 +186,43 @@ def find_replace_in_file(file_path, find_str, replace_str): def create_branch_if_not_exists(branch, commit_sha): response = requests.get(f"https://api.github.com/repos/{REPOSITORY}/branches/{branch}") if response.status_code == 404: - refs = {"ref": "refs/heads/" + branch, "sha": commit_sha} - response = requests.post( - f"https://api.github.com/repos/{REPOSITORY}/git/refs", - headers=HEADERS, - data=json.dumps(refs)) - if response.status_code == 201: - print(f"INFO: Branch created -> https://github.com/{REPOSITORY}/tree/{branch}") - else: - print("ERROR: branch not created") + branch_data = {"ref": "refs/heads/" + branch, "sha": commit_sha} + __create_branch(branch, branch_data) else: print(f"INFO: Branch -> https://github.com/{REPOSITORY}/tree/{branch}") def open_issue_for_package(package, current_version, latest_version): - issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: { - package}=={current_version} -> {latest_version}" - query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" - response = requests.get( - "https://api.github.com/search/issues", params={"q": query}) - data = response.json() - if data["total_count"] > 0: - issue_number = data['items'][0]['number'] - print(f"INFO: Issue -> https://github.com/{REPOSITORY}/issues/{issue_number}") - return issue_number - else: - issue_description = f""" + issue_number, old_title, old_description = __check_if_issue_already_exists(package, current_version, latest_version) + issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version} -> {latest_version}" + issue_description = f""" The package {package} is outdated in {REQUIREMENT_FILE}. The latest version is {latest_version}. Please update the package to the latest version. Check the package [here](https://pypi.org/project/{package}/{latest_version}/) for more information. - """ - issue = {"title": issue_title, - "body": issue_description, - "labels": ["automation"]} - response = requests.post( - f"https://api.github.com/repos/{REPOSITORY}/issues", - headers=HEADERS, - data=json.dumps(issue)) - if response.status_code == 201: - issue_number = response.json()['number'] - print(f"INFO: Issue created -> https://github.com/{REPOSITORY}/issues/{issue_number}") - return issue_number - else: - print(f"ERROR: Failed to create issue. Status code: {response.status_code}.") - return -1 + """ + issue = {"title": issue_title, + "body": issue_description, + "labels": ["automation"]} + if issue_number > 0: + comment = f""" +A new version of the package is out. +**Title and description is going to be updated with the latest one.** -def build_packages_dict_from_file(): - print("INFO: create dictionary from file") - packages = {} - with open(REQUIREMENT_FILE, 'r') as file: - lines = file.readlines() - for line in lines: - regex_pattern = re.compile( - "([a-zA-Z0-9-]+)==([0-9]+\.[0-9]+\.[0-9]+)") - matches = regex_pattern.findall(line) - if len(matches) > 0: - package_name = str(matches[0][0]) - package_version = str(matches[0][1]) - packages[package_name] = package_version - return packages - - -def build_packages_dict_from_output(output): - print("INFO: create dictionary from output") - packages = {} - lines = output.splitlines(output) - for line in lines: - regex_pattern = re.compile( - "([a-zA-Z0-9-]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([0-9]+\.[0-9]+\.[0-9]+)\ +([a-zA-Z]+)") - matches = regex_pattern.findall(line) - if len(matches) > 0: - package_name = str(matches[0][0]) - package_version = str(matches[0][2]) - packages[package_name] = package_version - return packages +**This is the previous title and description of this issue:** +``` +Title: {old_title} +Description: +{old_description} +``` + """ + __comment_issue(issue_number, comment) + __update_issue(issue_number, issue) + return issue_number + else: + return __create_issue(issue) if __name__ == '__main__': @@ -202,8 +231,8 @@ def build_packages_dict_from_output(output): raw_output_outdated = subprocess.run( ['pip3', 'list', '--outdated'], stdout=subprocess.PIPE) - current_packages = build_packages_dict_from_file() - latest_packages = build_packages_dict_from_output(raw_output_outdated.stdout.decode('utf-8')) + current_packages = __build_packages_dict_from_file() + latest_packages = __build_packages_dict_from_output(raw_output_outdated.stdout.decode('utf-8')) print("##### Create datas #####") packages_issue = {} if OPEN_PR == "True": @@ -218,10 +247,9 @@ def build_packages_dict_from_output(output): INFO: current version {current_version} INFO: latest version {latest_version}""") packages_issue[package] = open_issue_for_package( - package, current_version, latest_version) - - if ISSUE_AUTOCLOSE == "True": - close_issue_if_old(package, current_version, latest_version, packages_issue[package]) + package, + current_version, + latest_version) if OPEN_PR == "True": line_current = f"{package}==[0-9]+\.[0-9]+\.[0-9]+" From 040f93ec393bdbe75cd9784ab1ec422c6a9a3bc7 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:41:39 +0200 Subject: [PATCH 6/9] fix(workflows): update issue updater --- .../workflows/check_outdated_dependencies.yml | 3 +- workflows/check_outdate_deps/check_deps.py | 42 +++++++++---------- 2 files changed, 22 insertions(+), 23 deletions(-) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 28e94533c..1f7ae8021 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -24,5 +24,4 @@ jobs: GITHUB_SHA: ${{ secrets.GITHUB_SHA }} REQUIREMENT_FILE: "requirements-workflow.txt" OPEN_PR: "True" - OPEN_PR_BASE: "dev" - ISSUE_AUTOCLOSE: "True" + OPEN_PR_BASE: "main" diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py index 284825fd4..9de533acd 100644 --- a/workflows/check_outdate_deps/check_deps.py +++ b/workflows/check_outdate_deps/check_deps.py @@ -16,7 +16,6 @@ } OPEN_PR = os.environ.get("OPEN_PR") OPEN_PR_BASE = os.environ.get("OPEN_PR_BASE") -ISSUE_AUTOCLOSE = os.environ.get("ISSUE_AUTOCLOSE") BRANCH = "automation/dependencies_update" @@ -107,17 +106,6 @@ def __comment_issue(issue_number, comment): print(f"ERROR: Failed to create comment. Status code: {response.status_code}.") -def __check_if_issue_already_exists(package, current_version, latest_version): - issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" - query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" - items = __search_issues(query) - issue_title_latest = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version} -> {latest_version}" - for issue in items: - if issue['title'] != issue_title_latest: - return issue['number'], issue['title'], issue['body'] - return 0, "", "" - - def __create_pull_request(pr_data): response = requests.post( f"https://api.github.com/repos/{REPOSITORY}/pulls", @@ -135,7 +123,7 @@ def create_pull_request(branch, packages_issue): body = f"Bumps packages in {REQUIREMENT_FILE}." for package in packages_issue: body += f"\nCloses #{packages_issue[package]}" - title= f"Automation: update outdated packages in {REQUIREMENT_FILE}" + title = f"Automation: number outdated packages in {REQUIREMENT_FILE}" pr_data = { "title": title, "body": body, @@ -193,7 +181,9 @@ def create_branch_if_not_exists(branch, commit_sha): def open_issue_for_package(package, current_version, latest_version): - issue_number, old_title, old_description = __check_if_issue_already_exists(package, current_version, latest_version) + issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" + query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" + items = __search_issues(query) issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version} -> {latest_version}" issue_description = f""" The package {package} is outdated in {REQUIREMENT_FILE}. @@ -205,8 +195,17 @@ def open_issue_for_package(package, current_version, latest_version): issue = {"title": issue_title, "body": issue_description, "labels": ["automation"]} - if issue_number > 0: - comment = f""" + if not any(items): + return __create_issue(issue) + elif len(items) == 1: + issue_number = items[0]['number'] + old_title = items[0]['title'] + if old_title == issue_title: + print(f"INFO: Issue -> https://github.com/{REPOSITORY}/issues/{issue_number}") + return issue_number + else: + old_description = items[0]['body'] + comment = f""" A new version of the package is out. **Title and description is going to be updated with the latest one.** @@ -217,12 +216,13 @@ def open_issue_for_package(package, current_version, latest_version): Description: {old_description} ``` - """ - __comment_issue(issue_number, comment) - __update_issue(issue_number, issue) - return issue_number + """ + __comment_issue(issue_number, comment) + __update_issue(issue_number, issue) + return issue_number else: - return __create_issue(issue) + print(f"ERROR: More than 1 issues with the same title are found! I can't update.") + return -1 if __name__ == '__main__': From dc33ff2c5fd093e33692afacb14d7f500cbf1b14 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 5 Apr 2024 16:44:09 +0200 Subject: [PATCH 7/9] fix(.github/workflows): open pr to dev --- .github/workflows/check_outdated_dependencies.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 1f7ae8021..54b235301 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -24,4 +24,4 @@ jobs: GITHUB_SHA: ${{ secrets.GITHUB_SHA }} REQUIREMENT_FILE: "requirements-workflow.txt" OPEN_PR: "True" - OPEN_PR_BASE: "main" + OPEN_PR_BASE: "dev" From aa373d93c170cf2958305b5c3c80d231d52f2e02 Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Fri, 5 Apr 2024 18:07:46 +0200 Subject: [PATCH 8/9] fix(workflows): broken queries now fixed --- workflows/check_outdate_deps/check_deps.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/workflows/check_outdate_deps/check_deps.py b/workflows/check_outdate_deps/check_deps.py index 9de533acd..8013bd572 100644 --- a/workflows/check_outdate_deps/check_deps.py +++ b/workflows/check_outdate_deps/check_deps.py @@ -119,7 +119,7 @@ def __create_pull_request(pr_data): print(f"ERROR: Failed to create pull request. Status code: {response.status_code}.") return -1 -def create_pull_request(branch, packages_issue): +def manage_pull_request(branch, packages_issue): body = f"Bumps packages in {REQUIREMENT_FILE}." for package in packages_issue: body += f"\nCloses #{packages_issue[package]}" @@ -130,17 +130,17 @@ def create_pull_request(branch, packages_issue): "head": branch, "base": OPEN_PR_BASE } - query = f"{title} repo:{REPOSITORY} type:pull-request in:title" + query = f"{title} repo:{REPOSITORY} is:pr in:title state:open" items = __search_issues(query) if not any(items): __create_pull_request(pr_data) elif len(items) == 1: + pr_number = items[0]['number'] response = requests.patch( - f"https://api.github.com/repos/{REPOSITORY}/pulls/{items[0]}", + f"https://api.github.com/repos/{REPOSITORY}/pulls/{pr_number}", headers=HEADERS, data=json.dumps(pr_data)) if response.status_code == 200: - pr_number = response.json()['number'] print(f"INFO: Pull Request updated -> https://github.com/{REPOSITORY}/pull/{pr_number}") else: print(f"ERROR: Failed to update the pull requests. Status code: {response.status_code}.") @@ -182,7 +182,7 @@ def create_branch_if_not_exists(branch, commit_sha): def open_issue_for_package(package, current_version, latest_version): issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version}" - query = f"{issue_title} repo:{REPOSITORY} type:issue in:title" + query = f"{issue_title} repo:{REPOSITORY} is:issue in:title state:open" items = __search_issues(query) issue_title = f"Dependency outdated in {REQUIREMENT_FILE}: {package}=={current_version} -> {latest_version}" issue_description = f""" @@ -243,9 +243,8 @@ def open_issue_for_package(package, current_version, latest_version): if package in latest_packages: current_version = current_packages[package] latest_version = latest_packages[package] - print(f""" -INFO: current version {current_version} -INFO: latest version {latest_version}""") + print(f"INFO: current version {current_version}") + print(f"INFO: latest version {latest_version}") packages_issue[package] = open_issue_for_package( package, current_version, @@ -263,4 +262,4 @@ def open_issue_for_package(package, current_version, latest_version): print("----------------") if OPEN_PR == "True": update_branch_with_changes(BRANCH, REQUIREMENT_FILE) - create_pull_request(BRANCH, packages_issue) + manage_pull_request(BRANCH, packages_issue) From e71768c82eefc0bc0098b0ef005b36c21585d51d Mon Sep 17 00:00:00 2001 From: Wabri <12409541+Wabri@users.noreply.github.com> Date: Tue, 9 Apr 2024 10:02:03 +0200 Subject: [PATCH 9/9] fix(.github/workflow/check*): checkout to dev before the checks This prevents the issue creation when run after a merge into a different branch than the default one --- .github/workflows/check_outdated_dependencies.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check_outdated_dependencies.yml b/.github/workflows/check_outdated_dependencies.yml index 54b235301..519adbf5b 100644 --- a/.github/workflows/check_outdated_dependencies.yml +++ b/.github/workflows/check_outdated_dependencies.yml @@ -15,6 +15,8 @@ jobs: steps: - name: Check out the code uses: actions/checkout@main + with: + ref: "dev" - name: Check workflow dependencies uses: ./workflows/check_outdate_deps