From 16f269bd1c127d8fe1172d63befba7c19efcda1e Mon Sep 17 00:00:00 2001 From: "zuhao.peng" Date: Thu, 18 Dec 2025 14:14:24 +0800 Subject: [PATCH 1/3] modified: .github/workflows/dev.yaml --- .github/workflows/dev.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index c0175b3..f290851 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -1,9 +1,10 @@ name: dev on: + push: + branches: [dev] pull_request: - branches: - - dev + branches: [dev] types: [closed] workflow_dispatch: @@ -28,7 +29,8 @@ permissions: jobs: docker-opts: if: | - github.event_name == 'workflow_dispatch' || github.event.pull_request.merged == true + github.event_name == 'workflow_dispatch' || + (github.event_name == 'push' && github.event.pull_request.merged == true) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 From 7125bd2db7b7c2a0df6fe8415f36a6dc705b190d Mon Sep 17 00:00:00 2001 From: "zuhao.peng" <33852080+pengzuhao@users.noreply.github.com> Date: Thu, 18 Dec 2025 14:20:01 +0800 Subject: [PATCH 2/3] Add new workflow for dev branch CI/CD --- .github/workflows/dev2.yaml | 113 ++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 .github/workflows/dev2.yaml diff --git a/.github/workflows/dev2.yaml b/.github/workflows/dev2.yaml new file mode 100644 index 0000000..bfe1a85 --- /dev/null +++ b/.github/workflows/dev2.yaml @@ -0,0 +1,113 @@ +name: dev + +on: + push: + branches: [dev] + pull_request: + branches: [dev] + types: [closed] + workflow_dispatch: + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.base.ref || github.ref_name }} + cancel-in-progress: true + +env: + APP_NAME: assistant-us-dev + FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL_DEV }} + + REPO_DIR: mxrag-dev + REPO_URL: ${{ secrets.ALI_DOCKER_REGISTRY }} + REPO_USERNAME: ${{ secrets.ALI_DOCKER_REGISTRY_USERNAME_PENGHAO }} + REPO_PASSWORD: ${{ secrets.ALI_DOCKER_REGISTRY_PASSWD_PENGHAO }} + +permissions: + contents: read + packages: read + security-events: read + +jobs: + docker-opts: + if: | + github.event_name == 'workflow_dispatch' || + (github.event_name == 'push' && github.event.pull_request.merged == true) + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + with + ref: ${{ github.event.pull_request.base.ref }} + + - name: Get tag + shell: bash + run: | + datetime_now=$(TZ=Asia/Shanghai date "+%Y%m%d%H%M%S") + echo "DOCKER_TAG=${datetime_now}" >> $GITHUB_ENV + + - name: Log in to Aliyun ACR + run: | + docker login \ + -u ${{ env.REPO_USERNAME }} \ + -p ${{ env.REPO_PASSWORD }} \ + ${{ env.REPO_URL }} + + - name: Build and push Docker image + shell: bash + run: | + docker build -t ${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} . + docker push ${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} + + - name: Download saectl + shell: bash + run: | + wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250314/luedev/saectl-v0.1.5-linux-amd64.tar.gz + tar zxf saectl-v0.1.5-linux-amd64.tar.gz + sudo mv saectl /usr/bin/ + + - name: Restart sae + shell: bash + env: + ALICLOUD_ACCESS_KEY: ${{ secrets.ALICLOUD_ACCESS_KEY_PH }} + ALICLOUD_SECRET_KEY: ${{ secrets.ALICLOUD_SECRET_KEY_PH }} + ALICLOUD_REGION: ${{ secrets.ALICLOUD_REGION_SAE }} + run: | + saectl set image deploy/${{ env.APP_NAME }} main=${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} + + - name: Notify Feishu + if: always() + shell: bash + run: | + set -x + unset http_proxy + unset https_proxy + cd ${{ github.workspace }} + BUILD_STATUS="${{ job.status }}" + # COMMIT_MSG=$(git log -1 --pretty=format:"%s") + COMMIT_MSG=$(git log -1 --pretty=format:"%s"|awk 'NR==1{for (i=1; i<=NF; i++) printf "%s ", $i; print ""}') + COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an") + COMMIT_SHA=$(git log -1 --pretty=format:"%h") + + if [ "$BUILD_STATUS" = "success" ]; then + STATUS_TEXT=" Success" + else + STATUS_TEXT=" Failed" + fi + curl -H "Content-Type: application/json" -d "{ + \"msg_type\": \"post\", + \"content\": { + \"post\": { + \"zh_cn\": { + \"title\": \"${{ env.APP_NAME }}-dev - ${STATUS_TEXT}\", + \"content\": [ + [{\"tag\": \"text\",\"text\": \"Branch: ${{ github.event.pull_request.base.ref || github.ref_name }}\\n\"}], + [{\"tag\": \"text\",\"text\": \"Commit Message: ${COMMIT_MSG}\\n\"}], + [{\"tag\": \"text\",\"text\": \"Author: ${COMMIT_AUTHOR}\\n\"}], + [{\"tag\": \"text\",\"text\": \"Commit SHA: ${COMMIT_SHA}\\n\"}], + [{\"tag\": \"text\",\"text\": \"Build Status: ${STATUS_TEXT}\\n\"}], + [{\"tag\": \"text\",\"text\": \"Docker image tag: ${{ env.DOCKER_TAG }}\\n\"}] + ] + } + } + } + }" ${{ env.FEISHU_WEBHOOK_URL }} + + set +x From 8b178c808a60b508227e6a0709225705ef2105d4 Mon Sep 17 00:00:00 2001 From: "zuhao.peng" Date: Thu, 18 Dec 2025 14:22:41 +0800 Subject: [PATCH 3/3] modified: .github/workflows/dev.yaml --- .github/workflows/dev.yaml | 7 ++- .github/workflows/dev2.yaml | 113 ------------------------------------ 2 files changed, 4 insertions(+), 116 deletions(-) delete mode 100644 .github/workflows/dev2.yaml diff --git a/.github/workflows/dev.yaml b/.github/workflows/dev.yaml index f290851..efd4e85 100644 --- a/.github/workflows/dev.yaml +++ b/.github/workflows/dev.yaml @@ -30,12 +30,13 @@ jobs: docker-opts: if: | github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && github.event.pull_request.merged == true) + github.event_name == 'push' || + (github.event_name == 'pull_request' && github.event.pull_request.merged == true) runs-on: ubuntu-22.04 steps: - uses: actions/checkout@v4 - with - ref: ${{ github.event.pull_request.base.ref }} + with: + ref: ${{ github.event.pull_request.base.ref || github.ref }} - name: Get tag shell: bash diff --git a/.github/workflows/dev2.yaml b/.github/workflows/dev2.yaml deleted file mode 100644 index bfe1a85..0000000 --- a/.github/workflows/dev2.yaml +++ /dev/null @@ -1,113 +0,0 @@ -name: dev - -on: - push: - branches: [dev] - pull_request: - branches: [dev] - types: [closed] - workflow_dispatch: - -concurrency: - group: ${{ github.workflow }}-${{ github.event.pull_request.base.ref || github.ref_name }} - cancel-in-progress: true - -env: - APP_NAME: assistant-us-dev - FEISHU_WEBHOOK_URL: ${{ secrets.FEISHU_WEBHOOK_URL_DEV }} - - REPO_DIR: mxrag-dev - REPO_URL: ${{ secrets.ALI_DOCKER_REGISTRY }} - REPO_USERNAME: ${{ secrets.ALI_DOCKER_REGISTRY_USERNAME_PENGHAO }} - REPO_PASSWORD: ${{ secrets.ALI_DOCKER_REGISTRY_PASSWD_PENGHAO }} - -permissions: - contents: read - packages: read - security-events: read - -jobs: - docker-opts: - if: | - github.event_name == 'workflow_dispatch' || - (github.event_name == 'push' && github.event.pull_request.merged == true) - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v4 - with - ref: ${{ github.event.pull_request.base.ref }} - - - name: Get tag - shell: bash - run: | - datetime_now=$(TZ=Asia/Shanghai date "+%Y%m%d%H%M%S") - echo "DOCKER_TAG=${datetime_now}" >> $GITHUB_ENV - - - name: Log in to Aliyun ACR - run: | - docker login \ - -u ${{ env.REPO_USERNAME }} \ - -p ${{ env.REPO_PASSWORD }} \ - ${{ env.REPO_URL }} - - - name: Build and push Docker image - shell: bash - run: | - docker build -t ${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} . - docker push ${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} - - - name: Download saectl - shell: bash - run: | - wget https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20250314/luedev/saectl-v0.1.5-linux-amd64.tar.gz - tar zxf saectl-v0.1.5-linux-amd64.tar.gz - sudo mv saectl /usr/bin/ - - - name: Restart sae - shell: bash - env: - ALICLOUD_ACCESS_KEY: ${{ secrets.ALICLOUD_ACCESS_KEY_PH }} - ALICLOUD_SECRET_KEY: ${{ secrets.ALICLOUD_SECRET_KEY_PH }} - ALICLOUD_REGION: ${{ secrets.ALICLOUD_REGION_SAE }} - run: | - saectl set image deploy/${{ env.APP_NAME }} main=${{ env.REPO_URL }}/${{ env.REPO_DIR }}/${{ env.APP_NAME }}:${{ env.DOCKER_TAG }} - - - name: Notify Feishu - if: always() - shell: bash - run: | - set -x - unset http_proxy - unset https_proxy - cd ${{ github.workspace }} - BUILD_STATUS="${{ job.status }}" - # COMMIT_MSG=$(git log -1 --pretty=format:"%s") - COMMIT_MSG=$(git log -1 --pretty=format:"%s"|awk 'NR==1{for (i=1; i<=NF; i++) printf "%s ", $i; print ""}') - COMMIT_AUTHOR=$(git log -1 --pretty=format:"%an") - COMMIT_SHA=$(git log -1 --pretty=format:"%h") - - if [ "$BUILD_STATUS" = "success" ]; then - STATUS_TEXT=" Success" - else - STATUS_TEXT=" Failed" - fi - curl -H "Content-Type: application/json" -d "{ - \"msg_type\": \"post\", - \"content\": { - \"post\": { - \"zh_cn\": { - \"title\": \"${{ env.APP_NAME }}-dev - ${STATUS_TEXT}\", - \"content\": [ - [{\"tag\": \"text\",\"text\": \"Branch: ${{ github.event.pull_request.base.ref || github.ref_name }}\\n\"}], - [{\"tag\": \"text\",\"text\": \"Commit Message: ${COMMIT_MSG}\\n\"}], - [{\"tag\": \"text\",\"text\": \"Author: ${COMMIT_AUTHOR}\\n\"}], - [{\"tag\": \"text\",\"text\": \"Commit SHA: ${COMMIT_SHA}\\n\"}], - [{\"tag\": \"text\",\"text\": \"Build Status: ${STATUS_TEXT}\\n\"}], - [{\"tag\": \"text\",\"text\": \"Docker image tag: ${{ env.DOCKER_TAG }}\\n\"}] - ] - } - } - } - }" ${{ env.FEISHU_WEBHOOK_URL }} - - set +x