mirror of
https://github.com/carlospolop/privilege-escalation-awesome-scripts-suite.git
synced 2025-12-31 20:19:01 +00:00
actions
This commit is contained in:
53
.github/actions/aicoder/action.yml
vendored
Normal file
53
.github/actions/aicoder/action.yml
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
name: 'AICoder GH Action'
|
||||
description: 'A GitHub action that uses AICoder to generate PRs improving the code of files absed on prompts'
|
||||
author: 'carlospolop'
|
||||
inputs:
|
||||
INPUT_MODE:
|
||||
description: 'Mode of operation'
|
||||
required: true
|
||||
INPUT_PROMPT:
|
||||
description: 'Prompt for the AI'
|
||||
required: false
|
||||
INPUT_API_KEY:
|
||||
description: 'OpenAI API Key'
|
||||
required: true
|
||||
INPUT_MODEL:
|
||||
description: 'Model to use for AI'
|
||||
required: false
|
||||
TEMPLATE_FILES:
|
||||
description: 'Template files for file-generator mode'
|
||||
required: false
|
||||
CHECK_PATH:
|
||||
description: 'Path to file/folder to modify'
|
||||
required: false
|
||||
ORIGIN_BRANCH:
|
||||
description: 'Origin branch to checkout'
|
||||
required: true
|
||||
TO_BRANCH:
|
||||
description: 'Branch to commit changes'
|
||||
required: true
|
||||
runs:
|
||||
using: 'composite'
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v2
|
||||
- name: Set up Python
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: '3.x'
|
||||
- name: Install dependencies
|
||||
run: pip3 install aicoder
|
||||
shell: bash
|
||||
- name: Run AI Coder
|
||||
run: python3 gh-aicoder.py
|
||||
env:
|
||||
INPUT_MODE: ${{ inputs.INPUT_MODE }}
|
||||
INPUT_PROMPT: ${{ inputs.INPUT_PROMPT }}
|
||||
INPUT_API_KEY: ${{ inputs.INPUT_API_KEY }}
|
||||
INPUT_MODEL: ${{ inputs.INPUT_MODEL }}
|
||||
TEMPLATE_FILES: ${{ inputs.TEMPLATE_FILES }}
|
||||
ORIGIN_BRANCH: ${{ inputs.ORIGIN_BRANCH }}
|
||||
TO_BRANCH: ${{ inputs.TO_BRANCH }}
|
||||
CHECK_PATH: ${{ inputs.CHECK_PATH }}
|
||||
shell: bash
|
||||
|
||||
47
.github/actions/aicoder/gh-aicoder.py
vendored
Normal file
47
.github/actions/aicoder/gh-aicoder.py
vendored
Normal file
@@ -0,0 +1,47 @@
|
||||
import subprocess
|
||||
import os
|
||||
|
||||
# https://docs.github.com/en/actions/learn-github-actions/finding-and-customizing-actions
|
||||
def main(mode, prompt, api_key, model, path, template_files):
|
||||
|
||||
# Get inputs from env variables
|
||||
mode = os.environ.get("INPUT_MODE").lower()
|
||||
prompt = os.environ.get("INPUT_PROMPT", "")
|
||||
api_key = os.environ.get("INPUT_API_KEY")
|
||||
model = os.environ.get("INPUT_MODEL", "gpt-4")
|
||||
path = os.environ.get("CHECK_PATH", "")
|
||||
template_files = os.environ.get("TEMPLATE_FILES", "")
|
||||
orig_branch = os.environ.get("ORIGIN_BRANCH", "")
|
||||
to_branch = os.environ.get("TO_BRANCH", "")
|
||||
|
||||
#Allowed modes
|
||||
allowed_modes = ["file-enhancer", "file-generator", "file-security", "file-optimizer", "file-comments", "file-bugfixer"]
|
||||
if mode not in allowed_modes:
|
||||
raise ValueError(f"Mode must be one of {allowed_modes}")
|
||||
|
||||
# Construct the aicoder command based on the mode
|
||||
command = [
|
||||
"aicoder",
|
||||
mode,
|
||||
"--prompt", prompt,
|
||||
"--api-key", api_key,
|
||||
"--model", model,
|
||||
"--orig-branch", orig_branch,
|
||||
"--to-branch", to_branch
|
||||
]
|
||||
|
||||
if path:
|
||||
command.extend(["--path", path])
|
||||
elif template_files:
|
||||
command.extend(["--template-files", template_files])
|
||||
else:
|
||||
raise ValueError("Either path or template_files must be provided")
|
||||
|
||||
if path and template_files:
|
||||
raise ValueError("Either path or template_files must be provided")
|
||||
|
||||
if template_files and mode != "file-generator":
|
||||
raise ValueError("template_files can only be used with file-generator mode")
|
||||
|
||||
# Run the command
|
||||
subprocess.run(command)
|
||||
22
.github/workflows/aicoder.yml
vendored
Normal file
22
.github/workflows/aicoder.yml
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
name: aicoder
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Build_and_test_winpeas_master:
|
||||
runs-on: ubuntu
|
||||
|
||||
steps:
|
||||
# checkout
|
||||
- name: AICoder GH Action
|
||||
uses: ./.github/actions/aicoder
|
||||
with:
|
||||
INPUT_MODE: 'file-optimizer'
|
||||
INPUT_PROMPT: ''
|
||||
INPUT_API_KEY: ${{ secrets.OPENAI_API_KEY }}
|
||||
INPUT_MODEL: 'gpt-4'
|
||||
TEMPLATE_FILES: ''
|
||||
ORIGIN_BRANCH: 'aicoder'
|
||||
TO_BRANCH: 'master'
|
||||
CHECK_PATH: './parsers/json2pdf.py'
|
||||
Reference in New Issue
Block a user