diff --git a/src/bitwarden_workflow_linter/rules/run_actionlint.py b/src/bitwarden_workflow_linter/rules/run_actionlint.py index 6550175..a43a14d 100644 --- a/src/bitwarden_workflow_linter/rules/run_actionlint.py +++ b/src/bitwarden_workflow_linter/rules/run_actionlint.py @@ -3,40 +3,12 @@ from typing import Optional, Tuple import subprocess import platform -import shutil +import urllib from ..rule import Rule from ..models.workflow import Workflow from ..utils import LintLevels, Settings -def actionlint_download(): - # Step 1: Download the actionlint binary - url = "https://github.com/rhysd/actionlint/releases/download/v1.6.18/actionlint-linux-amd64" - download_path = "/tmp/actionlint" - - print("Downloading actionlint...") - subprocess.run(["sudo", "curl", "-L", url, "-o", download_path], check=True) - - # Step 2: Make the binary executable - print("Making actionlint executable...") - subprocess.run(["sudo", "chmod", "+x", download_path], check=True) - - # Step 3: Move the binary to a directory in the PATH (e.g., /usr/local/bin) - target_path = "/usr/local/bin/actionlint" - print(f"Moving actionlint to {target_path}...") - shutil.move(download_path, target_path) - - # Verify installation - print("Verifying installation...") - result = subprocess.run(["actionlint", "--version"], capture_output=True, text=True) - - if result.returncode == 0: - print("actionlint installed successfully!") - print(f"Version: {result.stdout.strip()}") - else: - print("Error occurred during installation.") - print(result.stderr) - def check_actionlint(): """Check if the actionlint is in the system's PATH. @@ -61,8 +33,14 @@ def check_actionlint(): ) except FileNotFoundError: if platform_system.startswith("Linux"): + url = "https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash" + version = '1.6.17' + request = urllib.request.open(url) + with open('download-actionlint.bash', 'w+') as fp: + fp.write(request.read()) try: - actionlint_download() + subprocess.run( + ['bash', ['install-actionlint.bash', version]], check=True) return True, "" except (FileNotFoundError, subprocess.CalledProcessError): error = "Failed to install Actionlint. \