From 9aff48fec75fd4d1f3eb5b4676ad1557b7abdf7e Mon Sep 17 00:00:00 2001 From: devcui Date: Thu, 21 Mar 2024 14:28:55 +0800 Subject: [PATCH] chore: chore ci --- .github/workflows/ci.yml | 58 ++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 908567a..218b69a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,106 +1,106 @@ name: CI on: - push: + pull_request: branches-ignore: - gh-pages + push: + branches: [main, master] jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: jwalton/gh-find-current-pr@v1 - id: findPr - with: - state: all - uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' - name: Comment on github + if: github.event.number run: node ./scripts/_ci/github-comment.js "RELEASE" "[Using release @yelon, Preview Preparing...](https://github.com/hbyunzai/ng-yunzai/actions/runs/${{ github.run_id }})" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} - name: Install node modules run: yarn install - name: Build run: ./scripts/_ci/deploy-pipelines.sh - name: 'Deploy Site' + if: github.event.number run: | - export DEPLOY_DOMAIN=https://preview-${{ github.event.number || steps.findPr.outputs.pr }}-ng-yunzai.surge.sh + export DEPLOY_DOMAIN=https://preview-${{ github.event.number }}-ng-yunzai.surge.sh echo "Deploy to $DEPLOY_DOMAIN" cp ./dist/browser/index.html ./dist/browser/404.html npx surge --project ./dist/browser --domain $DEPLOY_DOMAIN env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} - name: 'Update comment on github' + if: github.event.number run: | - export DEPLOY_DOMAIN=https://preview-${{ github.event.number || steps.findPr.outputs.pr }}-ng-yunzai.surge.sh + export DEPLOY_DOMAIN=https://preview-${{ github.event.number }}-ng-yunzai.surge.sh node ./scripts/_ci/github-comment.js "RELEASE" "[Preview is ready!]($DEPLOY_DOMAIN)" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} - name: 'When failed' - if: failure() + if: github.event.number && failure() run: node ./scripts/_ci/github-comment.js "RELEASE" "[Using release @yelon, Preview Failed](https://github.com/hbyunzai/ng-yunzai/actions/runs/${{ github.run_id }})" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} build-day: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: jwalton/gh-find-current-pr@v1 - id: findPr - with: - state: all - uses: actions/setup-node@v3 with: node-version-file: '.nvmrc' - name: Comment on github + if: github.event.number run: node ./scripts/_ci/github-comment.js "RELEASE_DAY" "[Using day release @yelon, Preview Preparing...](https://github.com/hbyunzai/ng-yunzai/actions/runs/${{ github.run_id }})" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} - name: Install node modules run: yarn install - name: Build run: ./scripts/_ci/deploy-pipelines.sh -day - name: 'Deploy Site' + if: github.event.number run: | - export DEPLOY_DOMAIN=https://preview-${{ github.event.number || steps.findPr.outputs.pr }}-day-ng-yunzai.surge.sh + export DEPLOY_DOMAIN=https://preview-${{ github.event.number }}-day-ng-yunzai.surge.sh echo "Deploy to $DEPLOY_DOMAIN" cp ./dist/browser/index.html ./dist/browser/404.html npx surge --project ./dist/browser --domain $DEPLOY_DOMAIN env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} SURGE_LOGIN: ${{ secrets.SURGE_LOGIN }} SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} - name: 'Update comment on github' + if: github.event.number run: | - export DEPLOY_DOMAIN=https://preview-${{ github.event.number || steps.findPr.outputs.pr }}-day-ng-yunzai.surge.sh + export DEPLOY_DOMAIN=https://preview-${{ github.event.number }}-day-ng-yunzai.surge.sh node ./scripts/_ci/github-comment.js "RELEASE_DAY" "[Using day release @yelon, Preview is ready!]($DEPLOY_DOMAIN)" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} - name: 'When failed' - if: failure() + if: github.event.number && failure() run: node ./scripts/_ci/github-comment.js "RELEASE" "[Using day release @yelon, Preview Failed](https://github.com/hbyunzai/ng-yunzai/actions/runs/${{ github.run_id }})" env: ACCESS_REPO: ${{ github.repository }} - ACCESS_TOKEN: ${{ secrets.CI_TOKEN }} - PR_NUMBER: ${{ github.event.number || steps.findPr.outputs.pr }} + ACCESS_TOKEN: ${{ secrets.PERSONAL_TOKEN }} + PR_NUMBER: ${{ github.event.number }} lint: runs-on: ubuntu-latest