# github workflow 设置 yaml 文件

name: Frontend pr workflow
on: # 在 develop 分支上触发 PR 的 build
    pull_request:
    branches: ["develop"]
jobs:
    build: # 任务名
        runs-on: [self-hostsd]
        steps: # 步骤列表
        - uses: actions/checkout@v3 # 步骤使用 actions 组织的 action,切换仓库,版本 v3
        - name: Use Node.js 16.xx.x # 使用内部 action
          uses: setupnoderepo
          with: # 此处为传参
            node-version: 16.xx.x
            registry-url: internal public repository url
        - name: cache npm dependencies # 使用 actions 组织的 action,仓库缓存
          uses: actions/cache@v3
          id: npm_cache
          with:
            path: node_modules
            key: $<!--swig0-->-node-$<!--swig1-->
        
        - name: install packages # 运行 bash 命令的步骤
          run: npm install
          if: steps.npm_cache.outputs.cache-hit != 'true' #只在没有缓存成功的状态下运行
        - run: npm run build # 运行 bash 命令
        - run: npm run test
        - name: install and start sonar analysis # 使用内部 action 仓库
          uses: xxx/sonar-xx@stable
          with:
            scanner-version: 'xxx'
            sonar-properties: 'sonar-project.properties'
            sonar-token: $<!--swig2--> # token 位于仓库的设置安全选项处
        #自定义 action 
        
        - name:my custom private github actions
          uses: ./.github/actions/frontend-ci # 这里不能使用 Org / 自己的仓库 @版本 只能使用相对路径
          with:
            docker-username: $<!--swig3-->
            docker-password: $
            sonar-dsp-token: $
            build-image: false
Edited on Views times