diff --git a/.github/azure-pipelines.yml b/.github/azure-pipelines.yml deleted file mode 100644 index 105a9a18c3..0000000000 --- a/.github/azure-pipelines.yml +++ /dev/null @@ -1,64 +0,0 @@ -name: Element Plus - -trigger: none - -pr: - autoCancel: true - branches: - exclude: - - gh-pages - -pool: - vmImage: 'ubuntu-latest' - -variables: - YARN_CACHE_FOLDER: $(Pipeline.Workspace)/.yarn - -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) diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml new file mode 100644 index 0000000000..af53e834c9 --- /dev/null +++ b/.github/workflows/preview-build.yml @@ -0,0 +1,50 @@ +name: Website Preview + +on: pull_request + +jobs: + build: + name: Build + runs-on: ubuntu-latest + env: + PULL_REQUEST_NUMBER: ${{ github.event.number }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup node + uses: actions/setup-node@v2 + + - name: Cache + uses: actions/cache@v2 + with: + path: node_modules + key: node_modules-${{ hashFiles('**/yarn.lock') }} + + - name: Install dependencies + run: yarn bootstrap + + - name: Build website + run: yarn website-build + + # share website dist + - name: Upload artifact + uses: actions/upload-artifact@v2 + with: + name: website + path: website-dist/ + retention-days: 1 + + # write pr.txt for share + - name: Save pr number + if: ${{ always() }} + run: echo ${PULL_REQUEST_NUMBER} > ./pr.txt + + # share pr number + - name: Upload pr number + if: ${{ always() }} + uses: actions/upload-artifact@v2 + with: + name: pr + path: ./pr.txt + retention-days: 1 diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml new file mode 100644 index 0000000000..d5c554d2ba --- /dev/null +++ b/.github/workflows/preview-deploy.yml @@ -0,0 +1,80 @@ +# This workflow runs on target, so there is no need to worry about secrets +name: Website Preview Deploy + +on: + workflow_run: + workflows: ['Website Preview'] + types: [completed] + +jobs: + # Build successfully, start deployment + on-success: + name: Build successfully + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download pr number + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + name: pr + + - name: Output pr number + id: pr + run: echo "::set-output name=id::$(