标签: github-actions

手动触发的 Github Action 总是被跳过

我有一个基于提交构建的工作 Github Action 文件。

我希望能够手动触发构建,因此我只添加了“workflow_dispatch”,并在 GUI 中看到了不错的选项按钮,我可以在其中选择要手动构建的分支。

但是当我选择一个分支(“dev”)并开始构建时,它总是被跳过?!

yml 文件位于我的“main”分支和所需的分支“dev”中

我的 yml 文件如下所示,“workflow_dispatch”是我唯一更改的内容:

name: Build for dev

on:
  workflow_dispatch:
  push:
    branches:
      - dev
  pull_request:
    types: [opened, synchronize, reopened, closed]
    branches:
      - dev

jobs:
  build_and_deploy_job:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.action != 'closed')
    runs-on: ubuntu-latest
    name: Build and Deploy Job
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: true
      - name: Build And Deploy
        id: builddeploy
        uses: Azure/static-web-apps-deploy@v0.0.1-preview
        with: …
Run Code Online (Sandbox Code Playgroud)

github-actions

5
推荐指数
1
解决办法
3664
查看次数

当触发新管道时取消之前的管道 GitHub Actions

我遇到了拦截器,我确信其他人一定也遇到过这个问题,所以只需检查是否有任何解决方法。

这是一个 Github 工作流程示例

name: Test Build
on:
  pull_request:
    types: [opened, synchronize, reopened]

jobs:
  app-1:
    runs-on: ubuntu-latest
    steps:
      - name: App-1
        run: echo "test1"
  app-2:
    runs-on: ubuntu-latest
    steps:
      - name: App-2
        run: echo "test1"
Run Code Online (Sandbox Code Playgroud)

现在,如果我多次提交,它将触发多个构建,这些构建将相互冲突并使管道失败。有没有办法可以取消该特定 PR 的正在运行的构建?

我看到有一个选择

concurrency: 
  group: CI-${GITHUB_REF#refs/heads/}
  cancel-in-progress: true
Run Code Online (Sandbox Code Playgroud)

但我不明白组在这里意味着什么,并发不是取消或跳过而是使构建失败。情况不应该是这样。我在这里错过了什么吗?

github-actions

5
推荐指数
1
解决办法
5885
查看次数

运行单元测试管道时 Github 操作错误

从昨天开始,我在 github 操作上运行单元测试时遇到了这个错误,我不明白为什么会发生这个错误。你能帮我解决这个问题吗?

> whisper-ui@1.0.0 test
> react-scripts test --coverage --watchAll=false --updateSnapshot



#
# Fatal error in , line 0
# Check failed: !holder_map.has_named_interceptor().
#
#
#
#FailureMessage Object: 0x7ffd7ab08610
 1: 0xb691f1  [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
 2: 0x1bf3094 V8_Fatal(char const*, ...) [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
 3: 0x10ac4a1 v8::internal::compiler::JSGlobalObjectRef::GetPropertyCell(v8::internal::compiler::NameRef const&, v8::internal::compiler::SerializationPolicy) const [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
 6: 0x1e61ba3 v8::internal::compiler::JSNativeContextSpecialization::ReduceNamedAccess(v8::internal::compiler::Node*, v8::internal::compiler::Node*, v8::internal::compiler::NamedAccessFeedback const&, v8::internal::compiler::AccessMode, v8::internal::compiler::Node*) [/opt/hostedtoolcache/node/16.9.0/x64/bin/node]
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)

这是我为 github action 编写的 yaml 代码

web_test:
    name: Web Tests
    runs-on: ubuntu-latest
    strategy:
      matrix:
        node-version: [14.x, 16.x]
    steps: …
Run Code Online (Sandbox Code Playgroud)

yaml node.js devops github-actions

5
推荐指数
1
解决办法
1392
查看次数

Github Action 不是按推送运行,而是按计划运行

根据这篇文章,我试图生成一个每次推送时运行的存储库,但也每 4 或 8 小时运行一次。从操作历史记录可以看出,只有其中一个成功,并且仅在 Mac 机器上:

但我的目标是在 ubuntu-latest、windows-latest 和 macos-latest 上运行它,以检查所有操作系统中的代码。最终目标是使计划推送的消息在 xxx 日期更新。这是我于 9 月 23 日编辑的最新代码,可以在这个 repo中看到:

name: render readme

on:
  push:
    paths:
      - README.Rmd
  schedule:
  - cron: 0 */4 * * *

jobs:
  render:
    runs-on: macOS-latest
    steps:
      - uses: actions/checkout@v2
      - uses: r-lib/actions/setup-r@v1
      - uses: r-lib/actions/setup-pandoc@v1
      - name: "[Custom block] [macOS] Install spatial libraries"
        if: runner.os == 'macOS'
        run: |
          # conflicts with gfortran from r-lib/actions when linking gcc …
Run Code Online (Sandbox Code Playgroud)

r r-markdown github-actions

5
推荐指数
1
解决办法
502
查看次数

有没有办法在 github actions 上运行 Web 应用程序

我正在开发一个仪表板 Web 应用程序,我想使用 Github 操作来部署和测试它。我已经成功编写了一个工作流程来构建和推送 docker 映像,但在测试它时遇到了问题。

它是一个 Vue 2 应用程序,监听端口 8080,测试是使用 Cypress 执行的。我的工作流程使用 docker-compose 来构建它以用于生产并通过 nginx 提供服务。当然,它适用于我公司服务器上的生产。

通过 Github Actions 部署时,nginx 执行和构建阶段正常运行,应用程序应该启动并运行,但在运行我的测试时,Cypress 在http://127.0.0.1:8080上抛出 ECONNREFUSED上抛出一个 ECONNREFUSED ,就像 github 阻止我一样应用程序侦听此端口或它正在外部容器中运行。

我认为必须有一种方法可以在 Github Actions 上运行和测试 Web 服务器,但我在文档或论坛中找不到它。

有谁知道如何实现这一目标?

这是我的 .yml github 工作流程的注释版本

name: Build and test
# event listener to trigger the workflow
on:
  push:
    branches:
      - 'workflows-dev'
      - 'master'

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2 # Checkout into the repo
      - run: sed -i -e "s/http\:\/\/<STRAPI_URL>/${{ secrets.PREPROD_URL …
Run Code Online (Sandbox Code Playgroud)

webserver github docker docker-compose github-actions

5
推荐指数
1
解决办法
903
查看次数

Gradle 中的 Kafka 集成测试遇到 GitHub Actions

我们一直在将我们公司的应用程序从 CircleCI 迁移到 GitHub Actions,但我们遇到了一个奇怪的情况。

项目代码没有任何变化,但我们的 kafka 集成测试在 GH Actions 机器上开始失败。在 CircleCI 和本地(MacOS 和 Fedora Linux 机器)中一切正常。

CircleCI 和 GH Actions 机器都运行 Ubuntu(测试版本为 18.04 和 20.04)。MacOS 未在 GH Actions 中进行测试,因为它没有 Docker。

以下是构建和集成测试使用的docker-compose和文件:workflow

  • docker-compose.yml
version: '2.1'

services:
  postgres:
    container_name: listings-postgres
    image: postgres:10-alpine
    mem_limit: 500m
    networks:
      - listings-stack
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: listings
      POSTGRES_PASSWORD: listings
      POSTGRES_USER: listings
      PGUSER: listings
    healthcheck:
      test: ["CMD", "pg_isready"]
      interval: 1s
      timeout: 3s
      retries: 30

  listings-zookeeper:
    container_name: listings-zookeeper
    image: confluentinc/cp-zookeeper:6.2.0
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: …
Run Code Online (Sandbox Code Playgroud)

apache-kafka docker docker-compose github-actions

5
推荐指数
1
解决办法
755
查看次数

Github 操作:NPM CI 错误:nice-napi 无法从 piscina 访问

我创建了一个简单的 Github 操作,用于对每个拉取请求构建和执行测试。没有更改代码后,突然停止工作。这是实际的操作代码:

name: Test pull request

on:
  pull_request:
    branches: [ develop ]
    paths-ignore:
      - 'apps/test/**'
      - 'apps/test-e2e/**'
      - 'libs/angular/**'

jobs:
  test_server_pull_request:

    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@master
      - uses: actions/setup-node@master
        with:
          node-version: 12
      - run: npm ci
      (...more build commands)
Run Code Online (Sandbox Code Playgroud)

package.json 实际上就是这个,实际上该项目是一个由 NX 管理的 monorepo,带有一些库、一个 NestJS 服务器应用程序和一个 Angular PWA:

{
"name": "sample",
"version": "0.0.1",
"license": "MIT",
"engines": {
    "node": "12"
},
"scripts": {
    ....some scripts
},
"private": true,
"dependencies": {
    "@angular/animations": "12.2.0",
    "@angular/cdk": "12.2.0",
    "@angular/common": "12.2.0",
    "@angular/compiler": "12.2.0",
    "@angular/core": …
Run Code Online (Sandbox Code Playgroud)

node.js angular nestjs github-actions

5
推荐指数
1
解决办法
3088
查看次数

错误:github 操作上“helm”的未知命令“chart”

我在 github 操作中针对 helm/kubernetes 的 CI 部署开始失败,并出现以下错误:

Error: unknown command "chart" for "helm" on github actions

在我的CI.yaml文件中,我有以下 helm 命令:


echo *****************
echo SAVING HELM CHART
echo *****************
# log in to aws and push the helm chart
aws ecr get-login-password --region us-west-2 | helm registry login --username AWS --password-stdin XXXX.amazonaws.com
helm chart save ./server-helm-chart/ XXXXX.amazonaws.com/test/helm:$helmChartVersion
echo *****************
echo PUSHING HELM CHART
echo *****************
helm chart push XXXX.amazonaws.com/test/helm:$helmChartVersion
Run Code Online (Sandbox Code Playgroud)

kubernetes-helm github-actions

5
推荐指数
1
解决办法
8936
查看次数

Bundle exec rubocop 在 Github Actions 上失败,但在本地运行成功

我正在尝试使用 Github Actions 设置 CI 管道。在bundle exec rubocop我的工作流程中它失败了。但是当在rails项目上运行时,该命令在本地完全通过。

name: CI - To check on linters and run test
on:
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  workflow_dispatch:

jobs:
  build-n-test:
    runs-on: ubuntu-latest
    env:
      RAILS_ENV: test

    steps:
      - uses: actions/checkout@v1
      - uses: ruby/setup-ruby@v1
        with:
          bundler-cache: true
      - name: RuboCop
        run: bundle exec rubocop
      
      - name: RSpec
        run: bundle exec rspec
Run Code Online (Sandbox Code Playgroud)

我在工作流程中可能缺少什么。

它失败了:

Unable to find gem rubocop-discourse; is the gem installed? Gem::MissingSpecError
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:278:in `rescue in gem_config_path'
/home/runner/work/drug_trial_mgmt_system/drug_trial_mgmt_system/vendor/bundle/ruby/3.0.0/gems/rubocop-1.22.0/lib/rubocop/config_loader_resolver.rb:268:in …
Run Code Online (Sandbox Code Playgroud)

rspec ruby-on-rails rubocop github-actions

5
推荐指数
1
解决办法
1728
查看次数

停止在更新存储库中的某些文件时触发 GitHub Actions

我有一个包含README.md文件并启用了 GitHub Actions 的存储库。每当我编辑README.md文件中的任何内容时,都会触发操作。如果我只更改,我不希望重建我的应用程序README.md

如何排除某些文件触发操作,就像我们有.gitignore文件排除某些文件被提交和推送一样。

github github-actions

5
推荐指数
1
解决办法
1502
查看次数