Skip to content

Commit da659c9

Browse files
szymon-czaprackisjanc
authored andcommitted
ci: Add workflow to sync .clang-format
If changes are detected, it updates the local file and automatically opens a pull request on the current repository to apply the update. This ensures consistent and up-to-date code formatting configuration. Uses: - GitHub Actions with cron trigger (daily at 06:00 UTC) - peter-evans/create-pull-request@v7 for automated PR creation [1]: https://github.com/peter-evans/create-pull-request
1 parent 3afbb0d commit da659c9

1 file changed

Lines changed: 68 additions & 0 deletions

File tree

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
20+
name: Sync clang-format
21+
22+
on:
23+
schedule:
24+
- cron: '0 6 * * *'
25+
26+
jobs:
27+
sync:
28+
runs-on: ubuntu-24.04
29+
permissions:
30+
contents: write
31+
pull-requests: write
32+
33+
if: github.event.repository.fork == false
34+
steps:
35+
- name: Checkout current repo
36+
uses: actions/checkout@v4
37+
38+
- name: Download .clang-format from source
39+
run: |
40+
wget -O .clang-format-core https://raw.githubusercontent.com/apache/mynewt-core/refs/heads/master/.clang-format
41+
42+
- name: Check for changes & replace
43+
id: changed
44+
run: |
45+
if ! cmp -s ".clang-format-core" ".clang-format"; then
46+
echo "🔄 .clang-format has changed, updating..."
47+
diff -u .clang-format .clang-format-core
48+
mv .clang-format-core .clang-format
49+
echo "changed=true" >> $GITHUB_OUTPUT
50+
else
51+
echo "✅ No changes detected."
52+
echo "changed=false" >> $GITHUB_OUTPUT
53+
fi
54+
55+
- name: Create Pull Request
56+
if: steps.changed.outputs.changed == 'true'
57+
uses: peter-evans/create-pull-request@v7
58+
with:
59+
author: Mynewt Bot <dev@mynewt.apache.org>
60+
token: ${{ secrets.GITHUB_TOKEN }}
61+
commit-message: |
62+
ci: Update .clang-format from apache-mynewt-core
63+
branch: update-clang-format
64+
title: "Update clang format"
65+
body: |
66+
Syncing the latest .clang-format file from apache-mynewt-core
67+
68+
[1]: https://github.com/peter-evans/create-pull-request

0 commit comments

Comments
 (0)