Add .bianbu-ci.yml

This commit is contained in:
James Deng 2024-10-28 15:02:35 +08:00
parent 05e1bd06f0
commit 0eba217851

62
.bianbu-ci.yml Normal file
View file

@ -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"