mirror of
https://github.com/element-plus/element-plus.git
synced 2025-01-24 11:05:17 +08:00
ci: add pr preview (#1241)
This commit is contained in:
parent
810c7b9955
commit
d2910b2986
@ -1,19 +1,64 @@
|
||||
# Starter pipeline
|
||||
# Start with a minimal pipeline that you can customize to build and deploy your code.
|
||||
# Add steps that build, run tests, deploy, and more:
|
||||
# https://aka.ms/yaml
|
||||
name: Element Plus
|
||||
|
||||
trigger:
|
||||
- main
|
||||
trigger: none
|
||||
|
||||
pr:
|
||||
autoCancel: true
|
||||
branches:
|
||||
exclude:
|
||||
- gh-pages
|
||||
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
- script: echo Hello, world!
|
||||
displayName: 'Run a one-line script'
|
||||
variables:
|
||||
YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn
|
||||
|
||||
- script: |
|
||||
echo Add other tasks to build, test, and deploy your project.
|
||||
echo See https://aka.ms/yaml
|
||||
displayName: 'Run a multi-line script'
|
||||
stages:
|
||||
- stage: Preview
|
||||
jobs:
|
||||
- job: Build_Preview
|
||||
steps:
|
||||
- checkout: self
|
||||
displayName: 'Checkout'
|
||||
clean: true
|
||||
fetchDepth: 1
|
||||
- task: NodeTool@0
|
||||
displayName: 'Install Node.js'
|
||||
inputs:
|
||||
versionSpec: '12.20.0'
|
||||
- task: Cache@2
|
||||
inputs:
|
||||
key: 'yarn | "$(Agent.OS)" | yarn.lock'
|
||||
restoreKeys: |
|
||||
yarn | "$(Agent.OS)"
|
||||
yarn
|
||||
path: $(YARN_CACHE_FOLDER)
|
||||
displayName: Cache Yarn packages
|
||||
- script: yarn bootstrap
|
||||
displayName: 'Project bootstrap'
|
||||
- script: yarn website-build
|
||||
displayName: 'Build website'
|
||||
- script: |
|
||||
export DEPLOY_DOMAIN=https://preview-${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}-element-plus.surge.sh
|
||||
echo "Deploy to $DEPLOY_DOMAIN"
|
||||
npx surge --project ./website-dist --domain $DEPLOY_DOMAIN
|
||||
displayName: 'Deploy Site'
|
||||
env:
|
||||
SURGE_LOGIN: $(SURGE_LOGIN)
|
||||
SURGE_TOKEN: $(SURGE_TOKEN)
|
||||
- script: |
|
||||
export DEPLOY_DOMAIN=https://preview-${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}-element-plus.surge.sh
|
||||
curl -X POST ${BOT_URL} -H 'Content-Type:application/json' --data-raw '{"botAction":"Preview", "pr":'${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}', "url":"'${DEPLOY_DOMAIN}'"}'
|
||||
displayName: 'Update PR comment'
|
||||
env:
|
||||
BOT_URL: $(BOT_URL)
|
||||
- job: Build_Preview_Failed
|
||||
dependsOn: Build_Preview
|
||||
condition: failed()
|
||||
steps:
|
||||
- script: |
|
||||
curl -X POST ${BOT_URL} -H 'Content-Type:application/json' --data-raw '{"status":"error", "botAction":"Preview", "pr":'${SYSTEM_PULLREQUEST_PULLREQUESTNUMBER}'}'
|
||||
displayName: 'Update PR comment'
|
||||
env:
|
||||
BOT_URL: $(BOT_URL)
|
||||
|
Loading…
Reference in New Issue
Block a user