Skip to content

Commit

Permalink
Merge pull request openyurtio#93 from luckymrwang/sync-charts
Browse files Browse the repository at this point in the history
chore: sync charts from raven to openyurt-helm
  • Loading branch information
njucjc authored Mar 14, 2023
2 parents 12d8a36 + d422466 commit 18e1569
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/sync-charts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Sync Charts

on:
push:
branches:
- master
paths:
- 'charts/**'

jobs:
sync-charts:
if: github.repository == 'openyurtio/raven'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Get the version
id: get_version
run: |
echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/}
echo ::set-output name=TAG::${GITHUB_REF#refs/tags/}
- name: Sync to openyurt-helm Repo
env:
SSH_DEPLOY_KEY: ${{ secrets.SYNC_CHARTS_SECRET }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
TAG: ${{ steps.get_version.outputs.TAG }}
COMMIT_ID: ${{ github.sha }}
run: |
bash ./hack/lib/sync-charts.sh
57 changes: 57 additions & 0 deletions hack/lib/sync-charts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash -l
# Copyright 2020 The OpenYurt Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -e

if [[ -n "$SSH_DEPLOY_KEY" ]]
then
mkdir -p ~/.ssh
echo "$SSH_DEPLOY_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
fi

echo "git clone"
cd ..
git config --global user.email "openyurt-bot@openyurt.io"
git config --global user.name "openyurt-bot"
git clone --single-branch --depth 1 git@github.com:openyurtio/openyurt-helm.git openyurt-helm

echo "clear openyurt-helm charts/raven"

if [ -d "openyurt-helm/charts/raven" ]
then
echo "charts raven exists, remove it"
rm -r openyurt-helm/charts/raven/*
else
mkdir -p openyurt-helm/charts/raven
fi

echo "copy folder raven/charts to openyurt-helm/charts"

cp -R raven/charts/raven-agent/* openyurt-helm/charts/raven-agent/

echo "push to openyurt-helm"
echo "version: $VERSION, commit: $COMMIT_ID, tag: $TAG"

cd openyurt-helm

if [ -z "$(git status --porcelain)" ]; then
echo "nothing need to push, finished!"
else
git add .
git commit -m "align with raven charts $VERSION from commit $COMMIT_ID"
git tag "$VERSION"
git push origin main
fi

0 comments on commit 18e1569

Please sign in to comment.