You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@echarts.apache.org by wa...@apache.org on 2023/06/26 03:45:24 UTC
[echarts] branch workflow/pr-preview updated: chore: add PR preview workflow
This is an automated email from the ASF dual-hosted git repository.
wangzx pushed a commit to branch workflow/pr-preview
in repository https://gitbox.apache.org/repos/asf/echarts.git
The following commit(s) were added to refs/heads/workflow/pr-preview by this push:
new bcb695c38 chore: add PR preview workflow
bcb695c38 is described below
commit bcb695c382a9a7839f916e156af68bcae418e2d5
Author: Zhongxiang Wang <yh...@all-my-life.cn>
AuthorDate: Mon Jun 26 11:45:20 2023 +0800
chore: add PR preview workflow
---
.github/workflows/ci.yml | 90 ++++++++++++++++++++++++++++++++++++++++++++++--
1 file changed, 87 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 12e06b1c1..f08b1a389 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,10 +2,15 @@ name: Node CI
on:
pull_request:
- types: [opened, synchronize]
+ types: [opened, reopened, synchronize, closed]
+
+concurrency:
+ group: ${{ github.workflow }}-${{ github.event.number }}
+ cancel-in-progress: true
jobs:
lint:
+ if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
strategy:
@@ -54,6 +59,7 @@ jobs:
run: npm run checktype
build:
+ if: ${{ github.event.action != 'closed' }}
runs-on: ubuntu-latest
strategy:
@@ -81,11 +87,89 @@ jobs:
if: steps.cache-dep.outputs.cache-hit != 'true'
run: npm ci
+ - name: Unit Test
+ run: npm run test
+
- name: Build release
run: npm run release
- name: Test generated DTS
run: npm run test:dts
- - name: Unit Test
- run: npm run test
+ - name: Pack npm tarball
+ id: pack-tarball
+ run: |
+ export NPM_PKG_DIR='.npm-pkg'
+ mkdir $NPM_PKG_DIR
+ npm pack -pack-destination $NPM_PKG_DIR
+ cd $NPM_PKG_DIR
+ find . -type f -regex ".*\.tgz" -exec tar xvzf {} \;
+ echo "PR_DIST_DIR=$NPM_PKG_DIR/package" >> $GITHUB_OUTPUT
+ echo "PR_DIST_CACHE_KEY=echarts-pr-dist-cache-${{ github.event.number }}@${{ github.event.pull_request.head.sha }}" >> $GITHUB_OUTPUT
+
+ - name: Cache PR dist files
+ uses: actions/cache@v3
+ id: cache-pr-dist
+ with:
+ key: ${{ steps.pack-tarball.outputs.PR_DIST_CACHE_KEY }}
+ path: ${{ steps.pack-tarball.outputs.PR_DIST_DIR }}
+
+ outputs:
+ PR_DIST_CACHE_KEY: ${{ steps.pack-tarball.outputs.PR_DIST_CACHE_KEY }}
+ PR_DIST_DIR: ${{ steps.pack-tarball.outputs.PR_DIST_DIR }}
+
+ pr-preview:
+ runs-on: ubuntu-latest
+ if: ${{ github.repository_owner == 'apache' && needs.build.result == 'success' }}
+ needs: ['build']
+
+ steps:
+ - name: Fetch cached PR dist files
+ uses: actions/cache@v3
+ with:
+ key: ${{ needs.build.outputs.PR_DIST_CACHE_KEY }}
+ path: ${{ needs.build.outputs.PR_DIST_DIR }}
+ fail-on-cache-miss: true
+
+ - name: Deploy dist files
+ run: |
+ cd ${{ needs.build.outputs.PR_DIST_DIR }}
+ export SURGE_DOMAIN='https://echarts-pr-${{ github.event.number }}.surge.sh'
+ npx surge --project ./ --domain $SURGE_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
+
+ - name: Install action dependencies
+ run: |
+ mkdir .actions
+ cd .actions
+ git clone --depth=1 https://github.com/actions-cool/maintain-one-comment.git
+
+ echo "GH_SHA_SHORT=$(echo ${{ github.event.pull_request.head.sha }} | cut -c 1-7)" >> $GITHUB_ENV
+
+ - name: Create comment for PR preview
+ uses: ./.actions/maintain-one-comment
+ with:
+ body: |
+ <!-- ECHARTS_PR_PREVIEW -->
+ The changes brought by this PR can be previewed at: https://echarts.apache.org/examples/editor?pr=${{ github.event.number }}@${{ env.GH_SHA_SHORT }}
+ body-include: '<!-- ECHARTS_PR_PREVIEW -->'
+ number: ${{ github.event.number }}
+
+ teardown-preview:
+ runs-on: ubuntu-latest
+ if: ${{ github.repository_owner == 'apache' && github.event.action == 'closed' && github.pull_request.merged != true }}
+ continue-on-error: true
+ steps:
+ - name: Install action dependencies
+ run: git clone --depth=1 https://github.com/actions-cool/maintain-one-comment.git
+
+ - name: Delete PR preview comment
+ uses: ./maintain-one-comment
+ with:
+ body-include: '<!-- ECHARTS_PR_PREVIEW -->'
+ delete: true
+ number: ${{ github.event.number }}
+
+ - name: Teardown closed PR preview
+ run: |
+ export SURGE_DOMAIN='https://echarts-pr-${{ github.event.number }}.surge.sh'
+ npx surge teardown $SURGE_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@echarts.apache.org
For additional commands, e-mail: commits-help@echarts.apache.org