bluetoothlover_doc icon indicating copy to clipboard operation
bluetoothlover_doc copied to clipboard

查看Git PR中的ChangeFile的技巧

Open supperthomas opened this issue 9 months ago • 1 comments

	        uses: actions/setup-python@main
        with:	        with:
          python-version: 3.8	          python-version: 3.8

      - name: Get changed files
        id: changed-files
        uses: tj-actions/changed-files@v45


      - name: List all changed files
        env:
          ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
        run: |
          # 初始化变量
          declare -a BSP_DIRECTORIES
          
          # 遍历所有发生变化的文件
          for file in ${ALL_CHANGED_FILES}; do
            # 判断文件路径是否包含 'bsp/' 并且是 'bsp' 的一级子目录
            if [[ "$file" == bsp/*/* && "$file" != *\/\/* ]]; then
              # 提取 'bsp/' 后的第一级目录(假设路径格式为 bsp/xxx/yyy/...)
              bsp_dir=$(dirname "$file" | awk -F'/' '{print $1 "/" $2}')
              echo "Extracted BSP directory: $bsp_dir"
              
              # 添加到数组中(如果不存在)
              if [[ ! " ${BSP_DIRECTORIES[@]} " =~ " ${bsp_dir} " ]]; then
                BSP_DIRECTORIES+=("$bsp_dir")
              fi
            fi
          done
          # 将结果暴露出去
          IFS=, # 设置分隔符为逗号
          echo "bsp_directories=${BSP_DIRECTORIES[*]}" >> $GITHUB_ENV
          
      - name: Install Tools	      - name: Install Tools
        shell: bash	        shell: bash
        run: |	        run: |
@@ -513,6 +543,7 @@ jobs:
          RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }}	          RTT_TOOL_CHAIN: ${{ matrix.legs.RTT_TOOL_CHAIN }}
          SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }}	          SRTT_BSP: ${{ join(matrix.legs.SUB_RTT_BSP, ',') }}
        run: |	        run: |
          echo "Detected BSP directories: ${{ env.bsp_directories }}"
          source ~/.env/env.sh	          source ~/.env/env.sh
          python tools/ci/bsp_buildings.py	          python tools/ci/bsp_buildings.py

supperthomas avatar Mar 08 '25 20:03 supperthomas

通过API查看PR的ChangeFile

- name: Get changed files
        id: changed_files
        if: github.event_name == 'pull_request'
        run: |
          changed_files=$(curl -s \
            "https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" | \
            jq -r '.[].filename') 
          echo "${changed_files}"

hydevcode avatar Apr 03 '25 12:04 hydevcode