创建了Signals and Systems (信号与系统 英文版) #185
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Check format | |
| on: | |
| pull_request_target: | |
| types: [opened, synchronize, reopened] | |
| branches: | |
| - master | |
| env: | |
| S3_URL: ${{ secrets.S3_URL }} | |
| ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY }} | |
| SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} | |
| BACKEND_URL: ${{ secrets.BACKEND_URL }} | |
| BACKEND_TOKEN: ${{ secrets.BACKEND_TOKEN }} | |
| BUCKET: ${{ vars.S3_BUCKET }} | |
| R2_URL: ${{ secrets.R2_URL }} | |
| R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }} | |
| R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }} | |
| R2_BUCKET: ${{ vars.R2_BUCKET }} | |
| FILELIST_URL: ${{ secrets.FILELIST_URL }} | |
| jobs: | |
| check-format: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v2 | |
| with: | |
| repository: ${{ github.event.pull_request.head.repo.full_name }} | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| - name: Show log | |
| run: git log -5 | |
| - name: Check for YAML files in root directory | |
| run: | | |
| files=$(find . -maxdepth 1 -type f \( -name "*.yml" -o -name "*.yaml" \)) | |
| if [ -n "$files" ]; then | |
| echo "根目录下发现 yml 或 yaml 文件,请移动到 metadata 目录中:" > comment.txt | |
| echo "$files" >> comment.txt | |
| exit 1 | |
| fi | |
| - id: pdfium | |
| name: Get pdfium-binaries latest | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| owner: bblanchon | |
| repo: pdfium-binaries | |
| - id: check | |
| name: Get byrdocs-check release | |
| uses: pozetroninc/github-action-get-latest-release@master | |
| with: | |
| owner: byrdocs | |
| repo: byrdocs-check | |
| - name: Download release | |
| run: | | |
| wget https://github.com/bblanchon/pdfium-binaries/releases/download/${{ steps.pdfium.outputs.release }}/pdfium-linux-x64.tgz | |
| tar --overwrite -zxvf pdfium-linux-x64.tgz | |
| wget https://github.com/byrdocs/byrdocs-check/releases/download/${{ steps.check.outputs.release }}/check-cmt -O check-cmt | |
| wget https://github.com/byrdocs/byrdocs-check/releases/download/${{ steps.check.outputs.release }}/check-pr -O check-pr | |
| chmod 777 check-cmt | |
| chmod 777 check-pr | |
| - name: Check | |
| env: | |
| DIR: ./metadata | |
| run: ./check-pr > comment.txt 2>&1 | |
| - name: Debug | |
| if: always() | |
| run: cat ./comment.txt | |
| - name: Read failure comment | |
| if: failure() | |
| id: comment | |
| run: | | |
| echo "body<<BYRDOCS_HEREDOC_EOF" >> $GITHUB_OUTPUT | |
| cat comment.txt >> $GITHUB_OUTPUT | |
| echo "BYRDOCS_HEREDOC_EOF" >> $GITHUB_OUTPUT | |
| - name: Request changes review | |
| if: github.event_name == 'pull_request_target' && failure() | |
| uses: ntsd/auto-request-changes-action@v3 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| review-message: ${{ steps.comment.outputs.body }} | |
| - name: Dismiss previous change requests | |
| if: success() | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const { data: reviews } = await github.rest.pulls.listReviews({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number | |
| }); | |
| for (const review of reviews) { | |
| if ( | |
| review.state === 'CHANGES_REQUESTED' && | |
| review.user.login === 'github-actions[bot]' | |
| ) { | |
| await github.rest.pulls.dismissReview({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| pull_number: context.payload.pull_request.number, | |
| review_id: review.id, | |
| message: '格式检查已通过,此更改请求已解决。' | |
| }); | |
| } | |
| } | |