|
1 | | -name: Uncrustify the source code |
| 1 | +name: Format Pull Request Files |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | issue_comment: |
5 | 5 | types: [created] |
6 | 6 |
|
| 7 | +env: |
| 8 | + bashPass: \033[32;1mPASSED - |
| 9 | + bashInfo: \033[33;1mINFO - |
| 10 | + bashFail: \033[31;1mFAILED - |
| 11 | + bashEnd: \033[0m |
| 12 | + |
7 | 13 | jobs: |
8 | | - Uncrustify: |
9 | | - name: Run_Uncrustify |
10 | | - if: ${{ github.event.issue.pull_request && github.event.comment.body == '/bot run uncrustify' }} |
| 14 | + Formatting: |
| 15 | + name: Run Formatting Check |
| 16 | + if: ${{ github.event.issue.pull_request }} && |
| 17 | + ( ( github.event.comment.body == '/bot run uncrustify' ) || |
| 18 | + ( github.event.comment.body == '/bot run formatting' ) ) |
11 | 19 | runs-on: ubuntu-20.04 |
12 | 20 | steps: |
13 | | - - name: Dump GitHub context |
14 | | - env: |
15 | | - GITHUB_CONTEXT: ${{ toJson(github) }} |
16 | | - run: echo "$GITHUB_CONTEXT" |
17 | | - - name: Install Utils |
18 | | - run: | |
19 | | - sudo apt-get update && sudo apt-get --assume-yes install software-properties-common curl jq sed |
20 | | - sudo add-apt-repository ppa:git-core/ppa |
21 | | - sudo apt-get update && sudo apt-get --assume-yes install git |
22 | | - git --version |
23 | | - - name: get pullrequest url |
24 | | - run: | |
25 | | - echo ${{ github.event.issue.pull_request.url }} |
26 | | - - name: get upstream repo |
27 | | - id: upstreamrepo |
28 | | - run: | |
29 | | - echo "RemoteRepo=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.repo.full_name' | sed 's/\"//g')" >> $GITHUB_OUTPUT |
30 | | - - name: get upstream branch |
31 | | - id: upstreambranch |
32 | | - run: | |
33 | | - echo "branchname=$(curl -H "Accept: application/vnd.github.sailor-v-preview+json" --url ${{ github.event.issue.pull_request.url }} | jq '.head.ref' | sed 's/\"//g')" >> $GITHUB_OUTPUT |
34 | | - - name: echo upstream repo:branch |
35 | | - run: | |
36 | | - echo ${{ steps.upstreamrepo.outputs.RemoteRepo }}:${{ steps.upstreambranch.outputs.branchname }} |
37 | | - - name: Checkout upstream repo |
38 | | - uses: actions/checkout@v3 |
39 | | - with: |
40 | | - repository: ${{ steps.upstreamrepo.outputs.RemoteRepo }} |
41 | | - ref: ${{ steps.upstreambranch.outputs.branchname }} |
42 | | - - name: Install Uncrustify |
43 | | - run: | |
44 | | - : # Install Uncrustify |
45 | | - echo "::group::Install Uncrustify" |
46 | | - sudo apt-get update && sudo apt-get --assume-yes install uncrustify |
47 | | - echo "::endgroup::" |
48 | | - - name: Run Uncrustify |
49 | | - run: | |
50 | | - : # Uncrustify on C files while ignoring symlinks. |
51 | | - : # Make a collapsible section in the log to run uncrustify |
52 | | - echo "::group::Uncrustify Check" |
53 | | - uncrustify --version |
54 | | - find . -iname "*.[ch]" | xargs uncrustify --no-backup --replace --if-changed -c tools/uncrustify.cfg -l C |
55 | | - echo "::endgroup::" |
56 | | - echo -e "\033[32;3mUncrustify Formatting Applied\033[0m" |
57 | | - - name: Push changes to upstream repository |
58 | | - run: | |
59 | | - : # Push changes to upstream repository |
60 | | - echo "::group::Push changes to upstream repository" |
61 | | - git config --global --add safe.directory '*' |
62 | | - git config --global user.name 'GitHub Action' |
63 | | - git config --global user.email '[email protected]' |
64 | | - git add -A |
65 | | - git commit -m "Uncrustify: triggered by comment." |
66 | | - echo "::endgroup::" |
67 | | - git push |
68 | | - if [ "$?" = "0" ]; then |
69 | | - echo -e "\033[32;3mPushed formatting changes, don't forget to run 'git pull'!\033[0m" |
70 | | - exit 0 |
71 | | - else |
72 | | - echo -e "\033[32;31mFailed to push the formatting changes\033[0m" |
73 | | - exit 1 |
74 | | - fi |
| 21 | + - name: Apply Formatting Fix |
| 22 | + uses: FreeRTOS/CI-CD-Github-Actions/formatting-bot@v2 |
| 23 | + id: check-formatting |
0 commit comments