Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions .github/workflows.yml

This file was deleted.

136 changes: 136 additions & 0 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
name: Build Preview Frontend

on:
push:
branches: [ main ]

jobs:
build_and_pack_frontend:
runs-on: ubuntu-20.04
steps:
- name: Install required packages
run: |
sudo apt-get update
sudo apt-get install -y zip unzip

- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22.7'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9.9.0

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build project
run: pnpm build

- name: Get date and commit hash
run: |
echo "DATE=$(date +'%Y%m%d')" >> $GITHUB_ENV
echo "COMMIT_HASH=${{github.sha}}" >> $GITHUB_ENV

- name: Truncate commit hash
run: |
HASH=${{ env.COMMIT_HASH }}
TRUNCATED_HASH=${HASH:0:8}
echo "TRUNCATED_HASH=${TRUNCATED_HASH}" >> $GITHUB_ENV

- name: Zip dist directory
run: zip -r preview-dist.zip ./dist

- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: preview-dist.zip
path: ./preview-dist.zip


release:
needs:
- build_and_pack_frontend
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Download From Artifacts
uses: actions/download-artifact@v3
with:
name: preview-dist.zip

- name: Set release name
run: |
DATE=$(date +"%Y%m%d")
SHORT_COMMIT_HASH=$(git rev-parse --short HEAD)
echo "RELEASE_NAME=v${DATE}-${SHORT_COMMIT_HASH}" >> $GITHUB_ENV

- name: Create release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
tag_name: ${{ env.RELEASE_NAME }}
release_name: Release Preview ${{ env.RELEASE_NAME }}
draft: false
prerelease: false

- name: Upload release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: preview-dist.zip
asset_name: preview-dist.zip
asset_content_type: application/zip

deploy_to_server:
needs:
- build_and_pack_frontend
runs-on: ubuntu-latest
steps:
- name: Download From Artifacts
uses: actions/download-artifact@v3
with:
name: preview-dist.zip

- name: Backup existing files
uses: appleboy/ssh-action@master
with:
host: legion-4g.yaklang.io
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /root/
if [ -d "preview-dist.zip" ]; then
mv preview-dist.zip preview-dist.zip.$(date +"%Y%m%d").bak
fi

- name: Upload dist files
uses: appleboy/scp-action@master
with:
host: legion-4g.yaklang.io
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: preview-dist.zip
target: /root/

- name: Deploy
uses: appleboy/ssh-action@master
with:
host: legion-4g.yaklang.io
username: root
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /root/
unzip -o preview-dist.zip
rm preview-dist.zip
55 changes: 55 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Build Production Frontend

on:
push:
tags:
- 'v*'

jobs:
build_and_push:
runs-on: ubuntu-20.04

steps:
- name: Check out repository
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '22.7'

- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: 9.9.0

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Build project
run: pnpm build

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1

- name: Login to Docker Hub
uses: docker/login-action@v1
with:
username: v1ll4n
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Get current date
id: date
run: echo "::set-output name=date::$(date +%F)"

- name: Build and push Docker image
uses: docker/build-push-action@v2
with:
context: ./
file: ./Dockerfile
# 所需要的体系结构,可以在 Available platforms 步骤中获取所有的可用架构
# platforms: linux/amd64,linux/arm64/v8
push: true
tags: |
v1ll4n/legion-frontend:${{ steps.date.outputs.date }}
v1ll4n/legion-frontend:latest
58 changes: 0 additions & 58 deletions .github/workflows/workflows.yml

This file was deleted.

13 changes: 13 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
FROM v1ll4n/api-server-base-aes:latest

COPY dist/index.html /var/www/html/index.html
COPY dist/asset-manifest.json /var/www/html/asset-manifest.json
COPY dist/static /var/www/html/static


COPY entrypoint.sh /entrypoint.sh

RUN chmod +x /entrypoint.sh

# 覆盖默认的启动命令
ENTRYPOINT ["/entrypoint.sh"]
25 changes: 25 additions & 0 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/sh
set -e
export DOLLAR='$'

echo "START TO CONFIG HTTPS"
echo DISABLE_HTTPS: $DISABLE_HTTPS;
if [[ $DISABLE_HTTPS == true ]]; then
echo '***DISABLE HTTPS***';
export HTTPS_DISABLE_COMMENT='# ';
echo '***HTTPS_DISABLE_COMMENT('$HTTPS_DISABLE_COMMENT')***';
else
echo '***HTTPS CONFIG ENABLE***';
fi
echo "-------------------------------------------------"

env
echo
echo "---------------------- START TO envsubst --------------------------"
envsubst < /etc/nginx/conf.d/default.conf.template > /etc/nginx/conf.d/default.conf
echo "envsubst FINISHED..."
echo "---------------------- /etc/nginx/conf.d/default.conf --------------------------"
cat /etc/nginx/conf.d/default.conf


nginx -g 'daemon off;'
6 changes: 3 additions & 3 deletions src/apis/task/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ const postTaskStart = (

// 任务列表 编辑回显
const getTaskStartEditDispaly = (
id: string,
): Promise<ResponseData<TableResponseData<any>>> =>
axios.get<never, ResponseData<TableResponseData<any>>>(
id: number,
): Promise<ResponseData<TPostTaskStartRequest>> =>
axios.get<never, ResponseData<TPostTaskStartRequest>>(
`/task/start/batch-invoking-script-task/fetch?id=${id}`,
);

Expand Down
7 changes: 4 additions & 3 deletions src/apis/task/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,23 +90,24 @@ type TNodeListRequest = Partial<{

type TPromptArgs = Partial<{
target: string;
'preset-protes': string[];
'preset-protes': string;
ports: string;
'enable-brute': boolean;
'enbale-cve-baseline': boolean;
execution_node: number;
plugins: string;
'scheduling-type': number;
timestamp: string[];
timestamp: number[];
interval_seconds: string;
interval_seconds_type: number;
execution_date: number;
}>;

type TPostTaskStartRequest = Partial<{
task_id: string;
task_group: string;
script_type: string;
prompt_args: TPromptArgs;
params: TPromptArgs;
scanner: string[];
first: boolean;
}>;
Expand Down
Loading