【问题标题】:Angular build not compiled correctly GitHub ActionsAngular 构建未正确编译 GitHub Actions
【发布时间】:2021-03-01 15:06:05
【问题描述】:

当标签被推送时,我正在使用 GitHub 操作来创建发布版本。但是,一旦它运行并且我检查了发布选项卡,它并没有正确创建发布。通常,当您运行ng build --prod 时,它会将您的所有代码编译成几个文件,从而大大减少文件大小。当我从发布选项卡下载项目时,这很正常,就像我在文件资源管理器中查看它一样。

这是我的工作流程 yaml 文件:

name: dev-release

on:

  create:

    tags:

      - v*

jobs:

  build:

    name: setup environment

    runs-on: ubuntu-latest

    strategy:

      matrix:

        node-version: [12.x]

    steps:

      - uses: actions/checkout@v2

        with:

          fetch-depth: 0

      - name: Cache node modules

        uses: actions/cache@v2.1.3

        with:

          path: ~/.npm

          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}

          restore-keys: |

            ${{ runner.os }}-node-

      - name: Node ${{ matrix.node-version }}

        uses: actions/setup-node@v1.4.4

        with:

          node-version: ${{ matrix.node-version }}

      - name: npm install

        run: |

          npm i

          npm run build:ci

      - name: Create Release

        uses: ncipollo/release-action@v1

        with:

          token: ${{ secrets.TOKEN }}

          draft: true

【问题讨论】:

  • 可以添加日志吗?
  • 我认为问题在于您没有在ncipollo/release-action@v1 中定义artifacts,因此它发布了当前字典。

标签: angular github continuous-integration github-actions


【解决方案1】:

请将artifacts 中的artifacts 定义为您的文件夹

artifacts:一组可选的路径,表示要上传到版本的工件。这可能是单个路径或以逗号分隔的路径列表(或 glob)。

查看日志似乎一切正常,因为代码已编译:

2020-11-18T11:01:59.5831738Z chunk {} runtime.1d195ead05122679a08a.js (runtime) 2.3 kB [entry] [rendered]
2020-11-18T11:01:59.5832939Z chunk {1} 1.c16b36d40a2635ee97c6.js () 174 kB  [rendered]
2020-11-18T11:01:59.5833729Z chunk {2} 2.5449d2e89a98cbd134fb.js () 37.2 kB  [rendered]
2020-11-18T11:01:59.5834534Z chunk {3} 3.fe05023c0dd4c02292ef.js () 53.6 kB  [rendered]
2020-11-18T11:01:59.5835659Z chunk {4} light.blue.yale.a040718431090d476d1d.css (light.blue.yale) 168 kB [initial] [rendered]
2020-11-18T11:01:59.5836819Z chunk {5} main.38262ff03d42f24493fc.js (main) 1.32 MB [initial] [rendered]
2020-11-18T11:01:59.5837887Z chunk {6} polyfills.55cc3ce773551d941d32.js (polyfills) 36 kB [initial] [rendered]
2020-11-18T11:01:59.5839256Z chunk {7} styles.d3fcf7ce8fd057dbb140.css (styles) 305 kB [initial] [rendered]
2020-11-18T11:01:59.5840306Z chunk {8} 8.e0c916486616e1903c4b.js () 275 kB  [rendered]

【讨论】:

  • 我已经添加了这个,但它似乎没有改变任何东西。如果我在 IDE 中执行此操作,该位置会是它构建的正常位置吗?还是我需要一个特殊的位置才能让它出现在 GitHub 发布部分? artifacts: "dist/angular-githubaction/*"
  • 我应该补充一点,我确实从操作中取回了文件,但是它们没有按预期压缩。
  • 抱歉,我不确定我们现在在哪里。所以你有你的文件在发布,但你希望它们被压缩,对吧?
  • 是的,文件显示在发布选项卡内,但它们并未像您在项目上运行 ng build 时所期望的那样压缩。
  • 您可以使用Archive using zip or tar 打包您的文件夹,然后将此压缩文件设置为工件。
猜你喜欢
  • 2021-04-29
  • 2021-12-30
  • 2022-06-12
  • 2020-04-15
  • 2022-12-03
  • 1970-01-01
  • 2020-04-26
  • 2019-02-12
  • 2021-07-11
相关资源
最近更新 更多