Skip to content

Commit

Permalink
Add Mirroring
Browse files Browse the repository at this point in the history
  • Loading branch information
hlwanghl committed Nov 4, 2019
1 parent 4641a1b commit dd76426
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
7 changes: 5 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,15 @@ branches:

jobs:
include:
- stage: check
script: ./build.sh
- stage: verify
script: ./build.sh verify
if: type = pull_request
- stage: deploy
script: ./build.sh deploy
if: type = push
- stage: mirror
script: ./build.sh mirror
if: type = cron

notifications:
slack: kubesphere:OAhuHKLZdksTBQGBUW6UapFn
43 changes: 33 additions & 10 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -120,19 +120,42 @@ injectGithubToken() {

pushUpdates() {
ensureVars GITHUB_USER GITHUB_TOKEN
git fetch
git checkout --track origin/gh-pages
local repo
for repo in $(ls $buildDir); do
mkdir -p $repo && mv $buildDir/$repo/* $repo/ && git add $repo
done
git commit -m "Update Charts" --author="KubeSphere CI Bot <[email protected]>"
git commit -m "Update" --author="KubeSphere CI Bot <[email protected]>"
injectGithubToken
echo "Pushing updates to GitHub ..."
git push origin HEAD:gh-pages
}

prepareHelm
updateRepos
[ -z "$updatedRepos" ] || [ "$1" != "deploy" ] || pushUpdates
verify() {
prepareHelm
updateRepos
}

deploy() {
verify

[ -z "$updatedRepos" ] || {
git fetch
git checkout --track origin/gh-pages
local repo
for repo in $(ls $buildDir); do
mkdir -p $repo && mv $buildDir/$repo/* $repo/ && git add $repo
done
pushUpdates
}
}

mirror() {
local original=https://kubernetes-charts.storage.googleapis.com
local mirrored=https://helm-chart-repo.pek3a.qingstor.com/kubernetes-charts
git fetch
git checkout --track origin/gh-pages
mkdir -p mirror
cd mirror
curl -L $original/index.yaml -o index.yaml
sed -i "s#$original#$mirrored#g" index.yaml

pushUpdates
}

$@

0 comments on commit dd76426

Please sign in to comment.