From 0eba21785123aa68ca76d4c4384d92d47b475eca Mon Sep 17 00:00:00 2001 From: James Deng Date: Mon, 28 Oct 2024 15:02:35 +0800 Subject: [PATCH] Add .bianbu-ci.yml --- .bianbu-ci.yml | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .bianbu-ci.yml diff --git a/.bianbu-ci.yml b/.bianbu-ci.yml new file mode 100644 index 0000000..fb59d0d --- /dev/null +++ b/.bianbu-ci.yml @@ -0,0 +1,62 @@ +variables: + WEBSITE_NAME: "bianbu-linux-website" + +default: + image: "harbor.bianbu.xyz/gitlab/node:v1" + before_script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - ssh-keyscan gitlab.dc.com >> ~/.ssh/known_hosts + - chmod 644 ~/.ssh/known_hosts + - git config --global user.name "Bianbu-CI" + - git config --global user.email "bianbu-ci@spacemit.com" + +stages: + - test + - review + +review-job: + stage: review + variables: + GIT_STRATEGY: none + script: + - echo "Downloading website code..." + - git clone --recurse-submodules git@gitlab.dc.com:bianbu/$WEBSITE_NAME.git + - cd $WEBSITE_NAME/submodules/$CI_PROJECT_NAME + - git checkout $CI_COMMIT_SHORT_SHA + - echo "Download complete." + - echo "Updating the submodule..." + - cd ../.. + - git add -u + - git commit -m "Update submodule $CI_PROJECT_NAME to $CI_COMMIT_SHORT_SHA" + - git push + - echo "Update complete." + rules: + - if: $CI_COMMIT_BRANCH == "main" + +pages: + stage: test + variables: + GIT_STRATEGY: none + BASE_URL: /-/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/ + script: + - echo "Downloading website code..." + - git clone --recurse-submodules git@gitlab.dc.com:bianbu/$WEBSITE_NAME.git + - cd $WEBSITE_NAME/submodules/$CI_PROJECT_NAME + - git checkout $CI_COMMIT_SHORT_SHA + - echo "Download complete." + - echo "Compiling the code..." + - cd ../.. + - npm --registry https://nexus.bianbu.xyz/repository/npmproxy/ install --no-strict-ssl + - bash prepare.sh + - npm run build + - echo "Compile complete." + - mv build ../public + artifacts: + paths: + - public/ + rules: + - if: $CI_PIPELINE_SOURCE == "merge_request_event"