Skip to content

Commit

Permalink
attempting to install actionlint from script
Browse files Browse the repository at this point in the history
  • Loading branch information
AmyLGalles committed Jan 6, 2025
1 parent 41b84e6 commit a39f6ad
Showing 1 changed file with 8 additions and 30 deletions.
38 changes: 8 additions & 30 deletions src/bitwarden_workflow_linter/rules/run_actionlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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. \
Expand Down

0 comments on commit a39f6ad

Please sign in to comment.