Skip to content

Commit

Permalink
Merge pull request #5 from scantist/PROD-6663-set-up-jenkins
Browse files Browse the repository at this point in the history
PROD-6663: Set up jenkins for auto deployment
  • Loading branch information
liuhahi committed May 4, 2023
2 parents 4af1c15 + 6bfd0ef commit b091ebf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
49 changes: 49 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
library 'jenkins-shared-lib@main'

pipeline {
agent {
docker {
image 'swr.ap-southeast-3.myhuaweicloud.com/scantist-images/frontend-build:v1.1.1'
registryUrl 'https://swr.ap-southeast-3.myhuaweicloud.com'
registryCredentialsId 'hwc-swr-cred'
args '-u root:root -v /var/run/docker.sock:/var/run/docker.sock'
}
}
environment {
GOOGLE_CHAT_TOKEN = credentials('google-chat-release-deployment-token')
GITHUB_CREDS = credentials('scantist-jenkins-bot')
SERVICE_ACCOUNT_KEY = credentials('scantist-v4-json')
}
stages {
stage('Download element-plus') {
steps {
sh'''
export GITHUB_OAUTH_TOKEN=$GITHUB_CREDS_PSW
bash scripts/download-element-plus
'''
}
}

stage('Build and upload to v4dev') {
environment {
GCP_CREDENTIALS_ID ='scantist-v4'
GCP_BUCKET = 'docs.scantist.io/'
GCP_FILE_PATTERN = 'docs/.vitepress/dist/**/*'
GCP_FILE_PATH_PREFIX = "docs/.vitepress/dist/"
}
steps {
sh '''
npm install
yarn docs:build
'''
step([$class: 'ClassicUploadStep',
credentialsId: env.GCP_CREDENTIALS_ID,
bucket: "gs://${env.GCP_BUCKET}",
pattern: env.GCP_FILE_PATTERN,
pathPrefix: env.GCP_FILE_PATH_PREFIX,
showInline: true])
pushHangoutsNotify("Deployed ${env.BRANCH_NAME} to docs.scantist.io.")
}
}
}
}
18 changes: 18 additions & 0 deletions scripts/download-element-plus
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/env bash

set -o errexit
set -o pipefail
set -o nounset

download_element_plus() {
version=$(jq -r '."dependencies"."element-plus"' package.json)
echo "Downloading $version"
tag=${version:18:10}
fetch --repo="https://github.com/scantist/element-plus" --tag="$tag" --release-asset="element-plus-$tag.tgz" .
}

main() {
download_element_plus
}

main

0 comments on commit b091ebf

Please sign in to comment.