Skip to content

Commit 08dddbf

Browse files
committed
workflows: Add workflow for syncing module with upstream
Since some modules owned by the Zephyr organization are not created as a Github fork maintaining them as a complete mirror requires manual pushing. To fix this add a reusable workflow that can be configured for each module to sync a specific branch in our version with upstream. Also adds a sample usage of said workflow for the LVGL module. Signed-off-by: Fabian Blatz <[email protected]>
1 parent e2feb66 commit 08dddbf

File tree

2 files changed

+77
-0
lines changed

2 files changed

+77
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Sync Upstream LVGL
2+
3+
on:
4+
schedule:
5+
- cron: "0 0 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
sync-lvgl:
10+
uses: ./.github/workflows/sync-module/sync-module.yml
11+
with:
12+
module_name: "lvgl"
13+
upstream_repository: "https://github.com/lvgl/lvgl"
14+
upstream_branch: "master"
15+
target_repository: "zephyrproject-rtos/lvgl"
16+
target_branch: "master"
17+
secrets:
18+
PAT_TOKEN: ${{ secrets.ZB_REPO_SYNC_GITHUB_TOKEN }}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: Reusable Sync Upstream
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
module_name:
7+
description: "Module name"
8+
required: true
9+
type: string
10+
upstream_repository:
11+
description: "Upstream repository URL"
12+
required: true
13+
type: string
14+
upstream_branch:
15+
description: "Upstream branch to sync from"
16+
required: true
17+
type: string
18+
target_repository:
19+
description: "Target repository URL"
20+
required: true
21+
type: string
22+
target_branch:
23+
description: "Target branch in the target repository"
24+
required: true
25+
type: string
26+
secrets:
27+
PAT_TOKEN:
28+
description: "GitHub Personal Access Token"
29+
required: true
30+
31+
jobs:
32+
sync:
33+
runs-on: ubuntu-latest
34+
35+
steps:
36+
- name: Checkout target repository
37+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8
38+
with:
39+
repository: ${{ inputs.target_repository }}
40+
ref: ${{ inputs.target_branch }}
41+
token: ${{ secrets.PAT_TOKEN }}
42+
path: repo-${{ inputs.module_name }}
43+
44+
- name: Configure Git
45+
run: |
46+
git config --global user.name "github-actions[bot]"
47+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
48+
49+
- name: Merge Upstream Changes (Fast-Forward)
50+
working-directory: repo-${{ inputs.module_name }}
51+
run: |
52+
git remote add upstream ${{ inputs.upstream_repository }}
53+
git fetch upstream ${{ inputs.upstream_branch }}
54+
git merge --ff-only upstream/${{ inputs.upstream_branch }} || (echo "Merge conflict detected. Please resolve manually." && exit 1)
55+
56+
- name: Push Changes to Target Repository
57+
working-directory: repo-${{ inputs.module_name }}
58+
run: |
59+
git push https://oauth2:${{ secrets.PAT_TOKEN }}@github.com/${{ inputs.target_repository }} HEAD:${{ inputs.target_branch }}

0 commit comments

Comments
 (0)