From 64d4726d3bf6c3bb7391b73f66ada65650c52659 Mon Sep 17 00:00:00 2001 From: rokkiter <101091030+rokkiter@users.noreply.github.com> Date: Fri, 4 Nov 2022 14:00:51 +0800 Subject: [PATCH 1/2] sync api by pipeline Signed-off-by: rokkiter <101091030+rokkiter@users.noreply.github.com> --- .github/workflows/sync-api.yml | 28 ++++++++++++ hack/sync-api.sh | 80 ++++++++++++++++++++++++++++++++++ 2 files changed, 108 insertions(+) create mode 100644 .github/workflows/sync-api.yml create mode 100755 hack/sync-api.sh diff --git a/.github/workflows/sync-api.yml b/.github/workflows/sync-api.yml new file mode 100644 index 000000000..e954c210c --- /dev/null +++ b/.github/workflows/sync-api.yml @@ -0,0 +1,28 @@ +name: Sync Api +on: + push: + paths: + - 'staging/src/github.com/clusterpedia-io/api/*' +jobs: + sync-api: + name: Sync Api + runs-on: ubuntu-latest + env: + WORKSPACE: ${{ github.workspace }}/src/github.com/clusterpedia-io/clusterpedia + GH_TOKEN: ${{ secrets.CLUSTERPEDIA_BOT_TOKEN }} + MESSAGE: ${{ github.event.head_commit.message }} + REFTYPE: ${{ github.ref_type }} + REFNAME: ${{ github.ref_name }} + REF: ${{ github.ref }} + defaults: + run: + working-directory: ${{ env.WORKSPACE }} + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + token: ${{ secrets.CLUSTERPEDIA_BOT_TOKEN }} + path: ${{ env.WORKSPACE }} + ref: ${{ github.ref }} + fetch-depth: 0 + - run: hack/sync-api.sh diff --git a/hack/sync-api.sh b/hack/sync-api.sh new file mode 100755 index 000000000..ad91f3bea --- /dev/null +++ b/hack/sync-api.sh @@ -0,0 +1,80 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + +function usage() { + cat < Date: Sat, 26 Nov 2022 09:49:57 +0800 Subject: [PATCH 2/2] hack/sync-api.sh: update api repo and temp dir Signed-off-by: Iceber Gu --- hack/sync-api.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hack/sync-api.sh b/hack/sync-api.sh index ad91f3bea..d8ee20595 100755 --- a/hack/sync-api.sh +++ b/hack/sync-api.sh @@ -33,7 +33,7 @@ if [ -z $REFNAME ]; then exit 1 fi -API_REPO="https://$GH_TOKEN@github.com/clusterpedia/api.git" +API_REPO="https://$GH_TOKEN@github.com/clusterpedia-io/api.git" install_filter_repo(){ python3 -m pip install --user git-filter-repo @@ -46,9 +46,9 @@ clean_tmp_dir(){ trap clean_tmp_dir EXIT create_tmp_dir(){ - mkdir -p $TMP_CLUSTERPEDIA - git clone ./ $TMP_CLUSTERPEDIA - cd $TMP_CLUSTERPEDIA + mkdir -p $TMP_CLUSTERPEDIA/api + git clone ./ $TMP_CLUSTERPEDIA/api + cd $TMP_CLUSTERPEDIA/api } # check tag, if exist, delete it