]> git.ipfire.org Git - thirdparty/git.git/blob - .github/workflows/check-whitespace.yml
ci: avoid using the deprecated `set-env` construct
[thirdparty/git.git] / .github / workflows / check-whitespace.yml
1 name: check-whitespace
2
3 # Get the repo with the commits(+1) in the series.
4 # Process `git log --check` output to extract just the check errors.
5 # Add a comment to the pull request with the check errors.
6
7 on:
8 pull_request:
9 types: [opened, synchronize]
10
11 jobs:
12 check-whitespace:
13 runs-on: ubuntu-latest
14 steps:
15 - name: Set commit count
16 shell: bash
17 run: echo "COMMIT_DEPTH=$((1+$COMMITS))" >>$GITHUB_ENV
18 env:
19 COMMITS: ${{ github.event.pull_request.commits }}
20
21 - uses: actions/checkout@v2
22 with:
23 fetch-depth: ${{ env.COMMIT_DEPTH }}
24
25 - name: git log --check
26 id: check_out
27 run: |
28 log=
29 commit=
30 while read dash etc
31 do
32 case "${dash}" in
33 "---")
34 commit="${etc}"
35 ;;
36 "")
37 ;;
38 *)
39 if test -n "${commit}"
40 then
41 log="${log}\n${commit}"
42 echo ""
43 echo "--- ${commit}"
44 fi
45 commit=
46 log="${log}\n${dash} ${etc}"
47 echo "${dash} ${etc}"
48 ;;
49 esac
50 done <<< $(git log --check --pretty=format:"---% h% s" -${{github.event.pull_request.commits}})
51
52 if test -n "${log}"
53 then
54 echo "::set-output name=checkout::"${log}""
55 exit 2
56 fi
57
58 - name: Add Check Output as Comment
59 uses: actions/github-script@v3
60 id: add-comment
61 with:
62 script: |
63 github.issues.createComment({
64 issue_number: context.issue.number,
65 owner: context.repo.owner,
66 repo: context.repo.repo,
67 body: "Whitespace errors found in workflow ${{ github.workflow }}:\n\n${{ steps.check_out.outputs.checkout }}"
68 })
69 if: ${{ failure() }}