From d4eca51e3b31c241bc40d9f392c47b6f154d819e Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Fri, 1 Nov 2024 19:08:21 -0400 Subject: [PATCH] Automate the changes to the github action template re #10079 --- arches/management/commands/updateproject.py | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arches/management/commands/updateproject.py b/arches/management/commands/updateproject.py index e0c4956cae..33c4a1f93b 100644 --- a/arches/management/commands/updateproject.py +++ b/arches/management/commands/updateproject.py @@ -51,3 +51,30 @@ def update_to_v8(self): os.remove(declarations_test_file_path) self.stdout.write("Done!") + + # Update certain lines in GitHub Actions workflows. + self.stdout.write("Updating GitHub Actions...") + action_path = os.path.join( + settings.APP_ROOT, + "..", + ".github", + "actions", + "build-and-test-branch", + "action.yml", + ) + if os.path.exists(action_path): + first_find = "python manage.py check\n" + first_replace = "python manage.py check --tag=compatibility\n" + second_find = "python manage.py makemigrations --check\n" + second_replace = "python manage.py makemigrations --check --skip-checks\n" + with open(action_path, "r") as f: + content = f.readlines() + for i, line in enumerate(content): + if line.endswith(first_find): + content[i] = line.replace(first_find, first_replace) + elif line.endswith(second_find): + content[i] = line.replace(second_find, second_replace) + with open(action_path, "w") as f: + f.writelines(content) + + self.stdout.write("Done!")