diff --git a/.github/workflows/test-build-site.yml b/.github/workflows/test-build-site.yml index 8169391b..7d64233f 100644 --- a/.github/workflows/test-build-site.yml +++ b/.github/workflows/test-build-site.yml @@ -1,17 +1,58 @@ -name: TEST_AND_BUILD +name: TEST_AND_BUILD_SITE on: workflow_call: jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: check_github_primary_email + run: | + log_emails=$(git log --pretty=format:"%ae %ce" -1) && if [[ ${log_emails} =~ '@tencent.com' ]];then echo "默认邮箱 $log_emails 校验非法,可以去 https://github.com/settings/emails 更改" && exit 2;else echo "邮箱 $log_emails 校验通过";fi + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.sha }} + - name: check_local_email + run: | + log_emails=$(git log --pretty=format:"%ae %ce" -1) && if [[ ${log_emails} =~ '@tencent.com' ]];then echo "本地提交邮箱 $log_emails 校验非法,需要本地更改重新提交" && exit 2;else echo "邮箱 $log_emails 校验通过";fi + + test: + # needs: check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + with: + submodules: recursive + - uses: actions/setup-node@v2 + with: + node-version: 18 + - uses: actions/cache@v2 + env: + cache-name: cache-nodemodules + with: + path: ~/.npm + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package.json') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + - run: npm install + - run: npm run lint + - run: npm run test + # upload report to codecov + - uses: codecov/codecov-action@v2 + with: + token: ${{ secrets.CODECOV_TOKEN }} + site: runs-on: ubuntu-latest # needs: test steps: - - uses: pnpm/action-setup@v3 - with: - version: 8 - uses: actions/checkout@v2 + with: + submodules: recursive - uses: actions/setup-node@v2 with: node-version: 18 @@ -25,7 +66,7 @@ jobs: ${{ runner.os }}-build-${{ env.cache-name }}- ${{ runner.os }}-build- ${{ runner.os }}- - - run: pnpm install + - run: npm install - name: Build site run: npm run site:preview