Skip to content

Commit

Permalink
feat(workflow): add Sync CSI Repos with Upstream action
Browse files Browse the repository at this point in the history
Signed-off-by: Derek Su <[email protected]>
  • Loading branch information
derekbit authored and innobead committed Oct 8, 2024
1 parent 1b18e5c commit a6a4272
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build-csi-sidecar-images.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build External Images
name: Build CSI Sidecar Images

on:
workflow_dispatch:
Expand Down
38 changes: 38 additions & 0 deletions .github/workflows/sync-csi-repos.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Sync CSI Repos with Upstream

on:
schedule:
# Every day at 3:00
- cron: '0 3 * * *'
workflow_dispatch:

defaults:
run:
shell: bash

env:
CARGO_TERM_COLOR: always

jobs:
release:
runs-on: ubuntu-latest

env:
GITHUB_TOKEN: ${{ secrets.CUSTOM_GITHUB_TOKEN }}

permissions:
contents: write

steps:
- name: Setup Git
run: |
gh auth setup-git
- run: |
git config --global user.email "[email protected]"
git config --global user.name "Derek Su"
- uses: actions/checkout@v4

- name: Sync Repos
run: bash ./scripts/sync-csi-repos-with-upstream.sh
32 changes: 32 additions & 0 deletions scripts/sync-csi-repos-with-upstream.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

source_target_repos=(
"external-snapshotter:csi-snapshotter"
"external-resizer:csi-resizer"
"external-provisioner:csi-provisioner"
"external-attacher:csi-attacher"
"node-driver-registrar:csi-node-driver-registrar"
"livenessprobe:livenessprobe"
)

for source_target_repo in "${source_target_repos[@]}"; do
source_repo=$(echo "$source_target_repo" | cut -d ":" -f 1)
target_repo=$(echo "$source_target_repo" | cut -d ":" -f 2)

echo "Syncing $target_repo"

SOURCE_REPO_PATH="https://github.com/kubernetes-csi/${source_repo}.git"
TARGET_REPO_PATH="https://github.com/longhorn/${target_repo}.git"

git clone ${TARGET_REPO_PATH}
pushd ${target_repo}

# Sync branches
git remote add src_remote ${SOURCE_REPO_PATH}
git fetch src_remote --quiet
git push origin "refs/remotes/src_remote/*:refs/heads/*" --force

# Sync tags
git fetch src_remote --tags --quiet
git push origin --tags --force
done

0 comments on commit a6a4272

Please sign in to comment.