Skip to content

Commit

Permalink
Merge branch 'main' into math-util
Browse files Browse the repository at this point in the history
  • Loading branch information
JiazhenBao authored Apr 23, 2024
2 parents 1be6e8c + 67892e7 commit b69e290
Show file tree
Hide file tree
Showing 155 changed files with 43,513 additions and 154 deletions.
171 changes: 171 additions & 0 deletions .github/workflows/check-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
# 为了试验,此处作为单独的 Workflow,在实际工作中可 Install -> Lint、Test -> Preview 串行检验
name: Check PR

# 执行 CI 的时机: 当 git push 到 main分支时
on:
pull_request:
branches: main

permissions:
pull-requests: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Check if commit is from CI
run: |
if [[ "${{ github.event.head_commit.committer.username }}" == "github-actions[bot]" ]]; then
echo "Commit is from CI, skipping the build..."
exit 78
else
echo "Commit is not from CI, continuing with the build..."
fi
- name: see vars
run: |
echo '${{github.event.pull_request.head.ref}}'
echo '${{github.event.pull_request.head.sha}}'
echo '${{github.event.pull_request.head.repo.branches_url}}'
echo '${{github.event.pull_request.head.repo.full_name}}'
echo '${{github.event.pull_request.base.ref}}'
echo '${{github.event.pull_request.base.sha}}'
echo '${{github.event.pull_request.base.repo.branches_url}}'
echo '${{github.event.pull_request.base.repo.full_name}}'
echo '${{github.head_ref}}'
echo '${{github.ref}}'
echo '${{github.ref_name}}'
echo '${{github.repository}}'
echo '${{ github.event.pull_request.number }}'
echo '${{ github.run_id }}'
echo '${{github.event.pull_request.user.name}}'
echo '${{github.event.pull_request.maintainer_can_modify}}'
echo '${{github.event.pull_request.user.id}}'
echo '${{github.event.sender.id}}'
echo '${{github.event.repository.fork}}'
echo '${{github.event.repository.name}}'
echo '${{github.event.repository.full_name}}'
echo '${{github.actor}}'
echo '${{github.triggering_actor}}'
echo '${{github.event.pull_request.user.name}}'
- name: Checkout
uses: actions/checkout/@v3
with:
fetch-depth: 1

- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
git fetch --unshallow
env:
GITHUB_TOKEN: ${{ github.token}}

- name: see git1
run: |
git branch --show-current
- name: see git2
run: |
git diff --name-only origin/main...HEAD
- name: Setup Nodejs
uses: actions/setup-node@v3
with:
cache: "npm"
node-version: 16

- name: Install Dep
run: |
npm install
- name: Detect Pull Request Change
run: |
git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
export LESSCHARSET=utf-8
npm run detectPR
{
echo "DIFF_STATE<<EOF"
echo "$(cat diff_stat.json)"
echo "EOF"
} >> "$GITHUB_ENV"
- name: Set up JDK 8
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
uses: actions/setup-java@v4
with:
java-version: "8"
distribution: "temurin"

- name: Install JDK Dependency
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
run: |
mvn install:install-file -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml"
mvn install:install-file -DgroupId=com.netease.lowcode -DartifactId=nasl-metadata-collector -Dversion=0.8.0 -Dpackaging=jar -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-collector-0.8.0.jar"
- name: Install LCAP
run: |
npm install -g [email protected]
lcap config set platform https://defaulttenant.lcap.hadri.163yun.com
lcap config set username admin
lcap config set password Admin@123456
- name: Check Pull Request
run: |
npm run checkPR
{
echo 'CHECK_RESULT<<EOF'
echo $(cat pr_result.json)
echo EOF
} >> "$GITHUB_ENV"
env:
GITHUB_TOKEN: ${{ github.token}}
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
HEAD_BRANCH_NAME: ${{github.head_ref}}
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}

- name: Upload PR Result Error
if: ${{fromJson(env.CHECK_RESULT).hasError}}
uses: actions/upload-artifact@v4
with:
name: pr_result
path: pr_result.json

- name: Exit If Error
if: ${{fromJson(env.CHECK_RESULT).hasError}}
run: |
exit 1
- name: Upload Assets
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
uses: actions/upload-artifact@v4
id: upload_assets
with:
name: dist
path: dist/

- name: Append Assets Download url
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
run: |
npm run successPR
env:
ARTIFACT_ID: ${{steps.upload_assets.outputs.artifact-id}}
GITHUB_TOKEN: ${{ github.token}}
PULL_REQUEST_ID: ${{ github.event.pull_request.number }}
HEAD_BRANCH_NAME: ${{github.head_ref}}
HEAD_REPOSITORY: ${{github.event.pull_request.head.repo.full_name}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}

- name: Upload PR Result Error
if: ${{fromJson(env.DIFF_STATE).packages[0]}}
uses: actions/upload-artifact@v4
with:
name: pr_result
path: pr_result.json
55 changes: 55 additions & 0 deletions .github/workflows/comment-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Comment on the pull request

# read-write repo token
# access to secrets
on:
workflow_run:
workflows: ['Check PR']
types:
- completed

permissions:
pull-requests: write

jobs:
upload:
runs-on: ubuntu-latest
if: >
github.event.workflow_run.event == 'pull_request'
steps:
- name: 'Download artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "pr_result"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/pr_result.zip`, Buffer.from(download.data));
- run: unzip pr_result.zip
- name: 'Comment on PR'
uses: actions/github-script@v6
with:
github-token: ${{ github.token }}
script: |
const fs = require('fs');
const fileContent = fs.readFileSync('./pr_result.json', 'utf-8');
const { message, pull_request_id } = JSON.parse(fileContent);
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: pull_request_id,
body: message
});
109 changes: 109 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
# 为了试验,此处作为单独的 Workflow,在实际工作中可 Install -> Lint、Test -> Preview 串行检验
name: Release

# 执行 CI 的时机: 当 git push 到 main分支时
on:
push:
branches: main

permissions:
pull-requests: write
issues: write
contents: write

jobs:
build:
# 仅在pr关闭后执行
if: startsWith(github.event.head_commit.message, 'Merge pull request ')
runs-on: ubuntu-latest

steps:
- name: Check if commit is from CI
run: |
if [[ "${{ github.event.head_commit.committer.username }}" == "github-actions[bot]" ]]; then
echo "Commit is from CI, skipping the build..."
exit 78
else
echo "Commit is not from CI, continuing with the build..."
fi
- name: see vars
run: |
echo '${{github.head_ref}}'
echo '${{github.ref}}'
echo '${{github.ref_name}}'
echo '${{github.repository}}'
echo '${{ github.run_id }}'
echo '${{github.event.sender.id}}'
echo '${{github.event.repository.fork}}'
echo '${{github.event.repository.name}}'
echo '${{github.event.repository.full_name}}'
echo '${{github.actor}}'
echo '${{github.triggering_actor}}'
- name: Checkout
uses: actions/checkout/@v3
with:
fetch-depth: 1
token: ${{secrets.RELEASE_TOKEN}}

- name: Git Identity
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/$GITHUB_REPOSITORY
git fetch --unshallow
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN}}

- name: Setup Nodejs
uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: 16

- name: Install Dep
run: |
npm install
- name: Detect Pull Request Change
run: |
git config --global core.quotepath false
git config --global gui.encoding utf-8
git config --global i18n.commit.encoding utf-8
git config --global i18n.logoutputencoding utf-8
export LESSCHARSET=utf-8
npm run detectPR from-release
{
echo "DIFF_STATE<<EOF"
echo "$(cat diff_stat.json)"
echo "EOF"
} >> "$GITHUB_ENV"
- name: Set up JDK 8
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
uses: actions/setup-java@v4
with:
java-version: '8'
distribution: 'temurin'

- name: Install JDK Dependency
if: ${{fromJson(env.DIFF_STATE).needJAVA}}
run: |
mvn install:install-file -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/nasl-metadata-maven-plugin-1.3.0.jar" -DpomFile="demo_bjz_JiazhenBao/jar/nasl-metadata-maven-plugin-1.3.0/pom.xml"
mvn install:install-file -DgroupId=com.netease.lowcode -DartifactId=nasl-metadata-collector -Dversion=0.8.0 -Dpackaging=jar -Dfile="demo_bjz_JiazhenBao/jar/nasl-metadata-collector-0.8.0.jar"
- name: Install LCAP
run: |
npm install -g [email protected]
lcap config set platform https://defaulttenant.lcap.hadri.163yun.com
lcap config set username admin
lcap config set password Admin@123456
- name: Check Pull Request
run: |
npm run release from-release
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN}}
HEAD_BRANCH_NAME: ${{github.head_ref}}
GITHUB_REPOSITORY: ${{github.repository}}
ACTION_ID: ${{github.run_id}}
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ build/

### node_modules ###
!**/node_modules/

dist/

node_modules/

**/dist-theme/
**/*.zip

**/target/


diff_stat.json
pr_result.json
test.md
3 changes: 3 additions & 0 deletions StringUtils_fdddf/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
target/
.DS_Store
Loading

0 comments on commit b69e290

Please sign in to comment.