From 9c93da223d37fc3c051b263584149a658dc9fd79 Mon Sep 17 00:00:00 2001 From: shanexi Date: Mon, 10 Mar 2025 11:09:29 +0800 Subject: [PATCH 1/3] ci: audit --- .github/workflows/audit.yaml | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/audit.yaml diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml new file mode 100644 index 00000000..b921ad8b --- /dev/null +++ b/.github/workflows/audit.yaml @@ -0,0 +1,37 @@ +name: Audit + +on: + pull_request: + branches: + - alpha + +jobs: + audit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 2 + + - name: Get last commit author email + id: get_email + run: echo "COMMIT_AUTHOR_EMAIL=$(git log -n 1 --pretty=format:%ae)" >> $GITHUB_ENV + + - name: Test author email + run: echo "The commit author email is $COMMIT_AUTHOR_EMAIL" + + - name: Get last commit author name + id: get_name + run: echo "COMMIT_AUTHOR_NAME=$(git log -n 1 --pretty=format:%an)" >> $GITHUB_ENV + + - name: Test author name + run: echo "The commit author name is $COMMIT_AUTHOR_NAME" + + - name: Get commit diff + run: | + git diff HEAD^ HEAD --unified=0 | grep "^[+]" | grep -v "^[+][+][+]" > commit_diff.txt + echo "查看 commit diff 的前几行:" + head -n 20 commit_diff.txt + echo "将 commit diff 发送到 webhook..." + PR_NUMBER=$(echo $GITHUB_REF | sed 's/refs\/pull\///' | sed 's/\/merge//') + curl -X POST -H "Content-Type: text/plain" -H "X-PR-Number: $PR_NUMBER" -H "x-secret: ${{ secrets.X_SECRET}}" --data-binary @commit_diff.txt ${{ secrets.N8N_AUDIT_WEBHOOK_TEST }} From 9624ccf45aa7892f71c93adb31cf26cd73775e68 Mon Sep 17 00:00:00 2001 From: shanexi Date: Mon, 10 Mar 2025 11:54:20 +0800 Subject: [PATCH 2/3] ci: to prod --- .github/workflows/audit.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index b921ad8b..0c7f58ca 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -34,4 +34,4 @@ jobs: head -n 20 commit_diff.txt echo "将 commit diff 发送到 webhook..." PR_NUMBER=$(echo $GITHUB_REF | sed 's/refs\/pull\///' | sed 's/\/merge//') - curl -X POST -H "Content-Type: text/plain" -H "X-PR-Number: $PR_NUMBER" -H "x-secret: ${{ secrets.X_SECRET}}" --data-binary @commit_diff.txt ${{ secrets.N8N_AUDIT_WEBHOOK_TEST }} + curl -X POST -H "Content-Type: text/plain" -H "X-PR-Number: $PR_NUMBER" -H "x-secret: ${{ secrets.X_SECRET}}" --data-binary @commit_diff.txt ${{ secrets.N8N_AUDIT_WEBHOOK }} From 2235507f48496d8af23f50923e97d66024f93239 Mon Sep 17 00:00:00 2001 From: shanexi Date: Mon, 10 Mar 2025 12:30:48 +0800 Subject: [PATCH 3/3] ci: remove sync to open-source --- .github/workflows/sync-open-source-main.yaml | 50 -------------------- .github/workflows/sync-open-source.yaml | 43 ----------------- 2 files changed, 93 deletions(-) delete mode 100644 .github/workflows/sync-open-source-main.yaml delete mode 100644 .github/workflows/sync-open-source.yaml diff --git a/.github/workflows/sync-open-source-main.yaml b/.github/workflows/sync-open-source-main.yaml deleted file mode 100644 index bab7178d..00000000 --- a/.github/workflows/sync-open-source-main.yaml +++ /dev/null @@ -1,50 +0,0 @@ -name: Sync open-source main - -on: - push: - branches: - - main - paths: - - ".yalc/**" - - "web/apps/web/**" - - "web/packages/**" - - ".github/**" - - "web/.yalc/image-canvas/**" - - "web/.yalc/myshell-bundled-chat/**" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Get last commit author email - id: get_email - run: echo "COMMIT_AUTHOR_EMAIL=$(git log -n 1 --pretty=format:%ae)" >> $GITHUB_ENV - - - name: Test author email - run: echo "The commit author email is $COMMIT_AUTHOR_EMAIL" - - - name: Get last commit author name - id: get_name - run: echo "COMMIT_AUTHOR_NAME=$(git log -n 1 --pretty=format:%an)" >> $GITHUB_ENV - - - name: Test author name - run: echo "The commit author name is $COMMIT_AUTHOR_NAME" - - - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: web - target-directory: web - destination-github-username: "myshell-ai" - destination-repository-name: "open-source" - target-branch: main - create-target-branch-if-needed: false - user-name: ${{ env.COMMIT_AUTHOR_NAME }} - user-email: ${{ env.COMMIT_AUTHOR_EMAIL }} - - - name: Test get variable exported by push-to-another-repository - run: echo $DESTINATION_CLONED_DIRECTORY diff --git a/.github/workflows/sync-open-source.yaml b/.github/workflows/sync-open-source.yaml deleted file mode 100644 index 5f62b5f7..00000000 --- a/.github/workflows/sync-open-source.yaml +++ /dev/null @@ -1,43 +0,0 @@ -name: Sync open-source - -on: - pull_request: - paths: - - ".yalc/**" - - "web/apps/web/**" - - "web/packages/**" - - ".github/**" - - "web/.yalc/image-canvas/**" - - "web/.yalc/myshell-bundled-chat/**" - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Get last commit author email - id: get_email - run: echo "COMMIT_AUTHOR_EMAIL=$(git log -n 1 --pretty=format:%ae)" >> $GITHUB_ENV - - - name: Test author email - run: echo "The commit author email is $COMMIT_AUTHOR_EMAIL" - - - uses: cpina/github-action-push-to-another-repository@main - env: - SSH_DEPLOY_KEY: ${{ secrets.SSH_DEPLOY_KEY }} - with: - source-directory: web - target-directory: web - destination-github-username: "myshell-ai" - destination-repository-name: "open-source" - target-branch: ${{ github.head_ref }} - create-target-branch-if-needed: true - user-name: ${{ github.event.pull_request.user.login }} - user-email: ${{ env.COMMIT_AUTHOR_EMAIL }} - # https://github.com/orgs/community/discussions/25191 - commit-message: See ${{github.repository}}@${{ github.event.pull_request.head.sha }} - - - name: Test get variable exported by push-to-another-repository - run: echo $DESTINATION_CLONED_DIRECTORY