diff --git a/.github/workflows/debian-check-keys.yml b/.github/workflows/debian-check-keys.yml index 44a9028d4..6e976991a 100644 --- a/.github/workflows/debian-check-keys.yml +++ b/.github/workflows/debian-check-keys.yml @@ -1,9 +1,28 @@ name: Debian Check Keys -on: workflow_call +on: + workflow_call: + outputs: + check_msg_env: + description: "output comment msg" + value: ${{ jobs.debian-check-keys.outputs.check_msg_all }} + check_status_env: + description: "check status" + value: ${{ jobs.debian-check-keys.outputs.check_status_all }} + check_msg: + description: "output comment msg for env" + value: ${{ jobs.debian-check-keys.outputs.check_msg_modify }} + check_status: + description: "check status for env" + value: ${{ jobs.debian-check-keys.outputs.check_status_modify }} jobs: debian-check-keys: runs-on: ubuntu-latest + outputs: + check_msg_all: ${{ steps.get-output.outputs.check_msg_all }} + check_status_all: ${{ steps.get-output.outputs.check_status_all }} + check_msg_modify: ${{ steps.get-output.outputs.check_msg_modify }} + check_status_modify: ${{ steps.get-output.outputs.check_status_modify }} continue-on-error: true strategy: matrix: @@ -28,24 +47,34 @@ jobs: - id: check-keys run: | check_result=$(python3 debianCheck/debianCheck/do-with-data.py ${check_type} ${check_keys} fetch-api-data-action/data.json) - echo "CHECK_RESULT=$check_result" >> $GITHUB_ENV + echo "check_result=$check_result" >> "$GITHUB_OUTPUT" env: check_type: ${{ matrix.check_type }} check_keys: ${{ matrix.check_keys }} - name: Publish reports id: artifact-upload-step - if: env.CHECK_RESULT == 'False' + if: steps.check-keys.outputs.check_result == 'False' uses: actions/upload-artifact@v4 with: name: words-check-report-${{ matrix.check_type }} path: result.json - - name: Comment PR - if: env.CHECK_RESULT == 'False' - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - 检测到敏感词${{matrix.check_keys}}变动:https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}/artifacts/${{steps.artifact-upload-step.outputs.artifact-id}} - - if: env.CHECK_RESULT == 'False' + - if: steps.check-keys.outputs.check_result == 'False' + id: get-result run: | echo "敏感词${{matrix.check_keys}}检查不通过" exit 1 + - name: Get Output + id: get-output + if: always() + env: + check_msg: | + 检测到敏感词${{matrix.check_keys}}变动: + https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}/artifacts/${{steps.artifact-upload-step.outputs.artifact-id}} + check_status: ${{ steps.get-result.outcome}} + run: | + { + echo "check_msg_${{ matrix.check_type }}<> "$GITHUB_OUTPUT" + echo "check_status_${{ matrix.check_type }}=$check_status" >> "$GITHUB_OUTPUT" \ No newline at end of file diff --git a/.github/workflows/debian-check-post.yml b/.github/workflows/debian-check-post.yml new file mode 100644 index 000000000..b226cad3b --- /dev/null +++ b/.github/workflows/debian-check-post.yml @@ -0,0 +1,59 @@ +name: Debian Check Post +on: + workflow_call: + inputs: + debian-check-prefix-status: + required: true + type: string + debian-check-prefix-msg: + required: true + type: string + debian-check-version-status: + required: true + type: string + debian-check-version-msg: + required: true + type: string + debian-check-key-status-env: + required: true + type: string + debian-check-key-msg-env: + required: true + type: string + debian-check-key-status: + required: true + type: string + debian-check-key-msg: + required: true + type: string + +jobs: + debian-check-post: + runs-on: ubuntu-latest + steps: + - id: get-comment-file + run: | + if [ ${{ inputs.debian-check-prefix-status }} == 'failure' ];then + echo "${{ inputs.debian-check-prefix-msg }}" >> comment.txt + fi + if [ ${{ inputs.debian-check-version-status }} == 'failure' ];then + echo "${{ inputs.debian-check-version-msg }}" >> comment.txt + fi + if [ ${{ inputs.debian-check-key-status-env }} == 'failure' ];then + echo "${{ inputs.debian-check-key-msg-env }}" >> comment.txt + fi + if [ ${{ inputs.debian-check-key-status }} == 'failure' ];then + echo "${{ inputs.debian-check-key-msg }}" >> comment.txt + fi + if [ -e 'comment.txt' ];then + sed -i '1i [Debian检查]:' comment.txt + fi + - name: Comment PR + if: hashFiles('comment.txt') + uses: thollander/actions-comment-pull-request@v2 + with: + filePath: comment.txt + - uses: ryaugusta/pr-add-reviewers-action@v1 + with: + token: ${{ secrets.BRIDGETOKEN }} + team_reviewers: Package-admins \ No newline at end of file diff --git a/.github/workflows/debian-check-prefix.yml b/.github/workflows/debian-check-prefix.yml index 366e64dc5..9acfe1afd 100644 --- a/.github/workflows/debian-check-prefix.yml +++ b/.github/workflows/debian-check-prefix.yml @@ -1,15 +1,27 @@ name: Debian Check Prefix -on: workflow_call +on: + workflow_call: + outputs: + check_msg: + description: "output comment msg" + value: ${{ jobs.debian-check-prefix.outputs.check_msg }} + check_status: + description: "check status" + value: ${{ jobs.debian-check-prefix.outputs.check_status }} jobs: debian-check-prefix: runs-on: ubuntu-latest + outputs: + check_msg: | + 检测到debian目录文件有变更: ${{ steps.get-changed-files.outputs.all_changed_files }} + check_status: ${{ steps.check-changed-files.outcome }} steps: - uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.sha }} - name: Get changed files - id: changed-files + id: get-changed-files uses: tj-actions/changed-files@v44 with: files: 'debian/**' @@ -21,18 +33,9 @@ jobs: debian/copyright debian/compat debian/source/format - - name: Comment PR - if: steps.changed-files.outputs.all_changed_files - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - 检测到debian目录文件有变更: **${{steps.changed-files.outputs.all_changed_files}}** - - name: List all changed files - if: steps.changed-files.outputs.all_changed_files - env: - DEBIAN_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }} + - name: Check changed files + id: check-changed-files + if: steps.get-changed-files.outputs.all_changed_files run: | - if [ ! -z ${DEBIAN_CHANGED_FILES} ]; then - echo "debian目录变动文件: $DEBIAN_CHANGED_FILES" - exit 1 - fi \ No newline at end of file + echo "debian目录变动文件: ${{ steps.get-changed-files.outputs.all_changed_files }}" + exit 1 \ No newline at end of file diff --git a/.github/workflows/debian-check-version.yml b/.github/workflows/debian-check-version.yml index a646e7dc1..1cb599828 100644 --- a/.github/workflows/debian-check-version.yml +++ b/.github/workflows/debian-check-version.yml @@ -1,9 +1,21 @@ name: Debian Check Version -on: workflow_call +on: + workflow_call: + outputs: + check_msg: + description: "output comment msg" + value: ${{ jobs.debian-check-version.outputs.check_msg }} + check_status: + description: "check status" + value: ${{ jobs.debian-check-version.outputs.check_status }} jobs: debian-check-version: runs-on: ubuntu-latest + outputs: + check_msg: | + 检测到debian/changelog版本变动异常: ${{ steps.check-version.outputs.version_str }} + check_status: ${{ steps.get-result.outcome }} steps: - uses: actions/checkout@v4 with: @@ -33,17 +45,10 @@ jobs: version1=$(echo $version_str|awk '{print $2}' || true) check_result=$(dpkg --compare-versions ${version0} gt ${version1} && echo true || echo false) fi - echo "CHECK_RESULT=$check_result" >> $GITHUB_ENV - echo "VERSION_STR=$version_str" >> $GITHUB_ENV - - name: Comment PR - if: github.env.CHECK_RESULT == 'false' - uses: thollander/actions-comment-pull-request@v2 - with: - message: | - 检测到debian/changelog版本变动异常: ${{github.env.VERSION_STR}} - - if: github.env.CHECK_RESULT == 'false' + echo "check_result=$check_result" >> "$GITHUB_OUTPUT" + echo "version_str=$version_str" >> "$GITHUB_OUTPUT" + - if: steps.check-version.outputs.check_result == 'false' + id: get-result run: | - if [[ "$CHECK_RESULT" == "false" ]];then - echo "debian/changelog版本变动异常:$VERSION_STR" - exit 1 - fi \ No newline at end of file + echo "debian/changelog版本变动异常:${{ steps.check-version.outputs.version_str }}" + exit 1 \ No newline at end of file diff --git a/.github/workflows/debian-check.yml b/.github/workflows/debian-check.yml index 95cbf54c8..05ed43375 100644 --- a/.github/workflows/debian-check.yml +++ b/.github/workflows/debian-check.yml @@ -10,3 +10,17 @@ jobs: uses: linuxdeepin/.github/.github/workflows/debian-check-version.yml@master call-debian-check-keys: uses: linuxdeepin/.github/.github/workflows/debian-check-keys.yml@master + post-debian-check: + if: failure() + needs: [call-debian-check-prefix, call-debian-check-version, call-debian-check-keys] + uses: linuxdeepin/.github/.github/workflows/debian-check-post.yml@master + secrets: inherit + with: + debian-check-prefix-status: ${{ needs.call-debian-check-prefix.outputs.check_status }} + debian-check-prefix-msg: ${{ needs.call-debian-check-prefix.outputs.check_msg }} + debian-check-version-status: ${{ needs.call-debian-check-version.outputs.check_status }} + debian-check-version-msg: ${{ needs.call-debian-check-version.outputs.check_msg }} + debian-check-key-status-env: ${{ needs.call-debian-check-keys.outputs.check_status_env }} + debian-check-key-msg-env: ${{ needs.call-debian-check-keys.outputs.check_msg_env}} + debian-check-key-status: ${{ needs.call-debian-check-keys.outputs.check_status }} + debian-check-key-msg: ${{ needs.call-debian-check-keys.outputs.check_msg }} \ No newline at end of file