Skip to content

Commit a6a4272

Browse files
derekbitinnobead
authored andcommitted
feat(workflow): add Sync CSI Repos with Upstream action
Signed-off-by: Derek Su <[email protected]>
1 parent 1b18e5c commit a6a4272

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

.github/workflows/build-csi-sidecar-images.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build External Images
1+
name: Build CSI Sidecar Images
22

33
on:
44
workflow_dispatch:

.github/workflows/sync-csi-repos.yml

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Sync CSI Repos with Upstream
2+
3+
on:
4+
schedule:
5+
# Every day at 3:00
6+
- cron: '0 3 * * *'
7+
workflow_dispatch:
8+
9+
defaults:
10+
run:
11+
shell: bash
12+
13+
env:
14+
CARGO_TERM_COLOR: always
15+
16+
jobs:
17+
release:
18+
runs-on: ubuntu-latest
19+
20+
env:
21+
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}
22+
23+
permissions:
24+
contents: write
25+
26+
steps:
27+
- name: Setup Git
28+
run: |
29+
gh auth setup-git
30+
31+
- run: |
32+
git config --global user.email "[email protected]"
33+
git config --global user.name "Derek Su"
34+
35+
- uses: actions/checkout@v4
36+
37+
- name: Sync Repos
38+
run: bash ./scripts/sync-csi-repos-with-upstream.sh
+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
source_target_repos=(
4+
"external-snapshotter:csi-snapshotter"
5+
"external-resizer:csi-resizer"
6+
"external-provisioner:csi-provisioner"
7+
"external-attacher:csi-attacher"
8+
"node-driver-registrar:csi-node-driver-registrar"
9+
"livenessprobe:livenessprobe"
10+
)
11+
12+
for source_target_repo in "${source_target_repos[@]}"; do
13+
source_repo=$(echo "$source_target_repo" | cut -d ":" -f 1)
14+
target_repo=$(echo "$source_target_repo" | cut -d ":" -f 2)
15+
16+
echo "Syncing $target_repo"
17+
18+
SOURCE_REPO_PATH="https://github.com/kubernetes-csi/${source_repo}.git"
19+
TARGET_REPO_PATH="https://github.com/longhorn/${target_repo}.git"
20+
21+
git clone ${TARGET_REPO_PATH}
22+
pushd ${target_repo}
23+
24+
# Sync branches
25+
git remote add src_remote ${SOURCE_REPO_PATH}
26+
git fetch src_remote --quiet
27+
git push origin "refs/remotes/src_remote/*:refs/heads/*" --force
28+
29+
# Sync tags
30+
git fetch src_remote --tags --quiet
31+
git push origin --tags --force
32+
done

0 commit comments

Comments
 (0)