标签: github-actions

有没有办法使用逻辑 AND 组合 GitHub 操作中的推送条件?

在 GitHub 操作“触发工作流的事件”文档中列出了多种方法,例如特定分支和特定路径更改。有没有办法使用 AND 将这两者结合起来?

据我了解,如果推送到主分支或特定路径,以下语法将触发运行。是否可以说必须满足这两个条件才能触发该操作?

on:
  push:
    branches:
    - master
    paths:
    - 'app/*'
Run Code Online (Sandbox Code Playgroud)

注意:我并不是在寻找一种黑客解决方案,比如让它在路径上触发,然后检查该分支是否是主分支。我知道这是可能的,但是您需要为每个步骤执行此操作,而且它一点也不优雅。

git github github-actions

6
推荐指数
1
解决办法
2187
查看次数

GitHub Action - 错误未定义:在参考或输入中找不到标签

我正在尝试创建一个 GitHub 操作,该操作将检测某个分支何时发生更改,然后构建一个版本。I\xe2\x80\x99m 遇到的问题是在我的 yml 文件中我使用这一行:

\n

ncipollo/release-action@v1. 这需要有一个可用的标签,否则将会失败。我已经创建并推送了一个标签,但是当我运行该操作时出现此错误

\n
Error undefined: No tag found in ref or input!\n
Run Code Online (Sandbox Code Playgroud)\n

这是我的 yml 文件:

\n
# Creates a release whenever a new change gets pushed onto the dev branch\n# https://github.com/ncipollo/release-action\n\nname: Dev-Build\non:  \n  push:\n    branches:\n      - dev\njobs:\n  build:\n    name: setup environment \n    runs-on: ubuntu-latest\n    strategy:\n      matrix:\n        node-version: [12.x]\n\n    steps:\n      - uses: actions/checkout@v2\n        with:\n          fetch-depth: 0\n      - name: Cache node modules\n        uses: actions/cache@v2.1.3\n        with:\n          path: ~/.npm\n          key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}\n          restore-keys: …
Run Code Online (Sandbox Code Playgroud)

continuous-integration github angular github-actions

6
推荐指数
1
解决办法
2664
查看次数

GitHub 行动 | 触发除一个子文件夹之外的根文件夹的管道

我想在文件夹的目录或子目录中更改任何文件时触发管道,/ProjectA/除了/ProjectA/sub-dir-a.

我添加了以下事件来实现结果,但是,它抛出一个错误,指出无法在同一事件中添加 Path 和 Path-ignore。

    on:
  push:
    branches: [ master ]
    paths: "ProjectA/**"
    paths-ignore: " ProjectA/sub-dir-a /**"
Run Code Online (Sandbox Code Playgroud)

收到错误 在此输入图像描述

此外,如果我将事件更改为仅包含“路径”,即使子文件夹中的任何文件也发生更改,它也会触发管道。

我正在寻找排除子目录的选项。

github-actions

6
推荐指数
1
解决办法
3517
查看次数

GitHub Actions 可以从私有存储库创建到公共存储库的发布吗?

我想创建一个包含可供用户下载的资源的版本。由于它是一个私人存储库,因此我想在单独的公共存储库中创建该版本。这在 GitHub Actions 中可行吗?

create-release操作中有ownerrepo参数,但将它们设置为不同的存储库后我不断收到错误:

   - name: Create Release
     id: create_release
     uses: actions/create-release@v1
     env:
       GITHUB_TOKEN: ${{ secrets.PAT }} # A personal access token
     with:
       tag_name: ${{ github.ref }}
       release_name: Release ${{ github.ref }}
       draft: false
       prerelease: false
       owner: foo
       repo: another_public_repo
Run Code Online (Sandbox Code Playgroud)

错误:验证失败:{"resource":"Release","code":"custom","field":"tag_name","message":"tag_name 不是有效标签"}, {"resource":" Release","code":"custom","message":"发布的版本必须具有有效的标签"}, {"resource":"Release","code":"invalid","field":"target_commitish" }

github-actions

6
推荐指数
1
解决办法
2551
查看次数

如何从 Github 包注册表下载特定发布版本的 JAR

目标

我想要两个存储库:

  • 存储库 A:将 JAR 发布到 Github 注册表

  • 存储库 B:从 A 下载 JAR 并发布包含 JAR 的 Docker 映像。


即我正在寻找一个如下所示的 API:

wget https://github.com/repoOwner/repoName/packages/1.2.3/my.jar
Run Code Online (Sandbox Code Playgroud)

问题

是否有 Github Action 或 API 允许我从 Github 包注册表下载特定版本的工件?

问题

我知道有一个用于工件的 Github API,但我不知道如何请求特定版本的工件 URL 。

github-actions github-package-registry

6
推荐指数
1
解决办法
5717
查看次数

Angular 应用程序无法使用 GitHub Actions 构建(“找不到模块”)

我可以在本地构建我的项目(使用我的 GitHub Action 使用的相同构建命令)。但是,在管道中运行时失败,并出现以下错误(还有更多,但基本相同的错误)。

ERROR in src/app/root-store/actions.ts:3:32 - error TS2307: Cannot find module '../shared/models/view-models/NewUserRequest'.

3 import { NewUserRequest } from '../shared/models/view-models/NewUserRequest';
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/root-store/frame-store/actions.ts:3:41 - error TS2307: Cannot find module 'src/app/shared/models/requests/FrameRequests'.

3 import { CreateFrameImageRequest } from 'src/app/shared/models/requests/FrameRequests';
                                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/app/shared/models/translators/frameTranslator.ts:4:61 - error TS2307: Cannot find module '../requests/FrameRequests'.
Run Code Online (Sandbox Code Playgroud)

它无法解析我导入到组件中的某些文件。它说“找不到模块”,但这些只是打字稿接口文件,它们不在模块中。我是 GitHub Actions 的新手,真的不知道如何开始调试此类问题。

这是我的 actions.yml 文件

# This is a basic workflow to help you get started with Actions

name: Build

# Controls when the action will run.
on:
  # Triggers the workflow …
Run Code Online (Sandbox Code Playgroud)

git typescript angular github-actions

6
推荐指数
1
解决办法
2636
查看次数

Github Action 测试 Laravel 8 失败

GitHub 操作在 laravel 8 上失败,使用Laravel By GitHub Actions

运行时出现问题

作曲家安装-q --no-ansi --no-interaction --no-scripts --prefer-dist

composer install -q --no-ansi --no-interaction --no-scripts --prefer-dist
  shell: /bin/bash -e {0}
Your lock file does not contain a compatible set of packages. Please run composer update.
Error: Process completed with exit code 2.
Run Code Online (Sandbox Code Playgroud)

这也是一个新鲜的 Laravel 8 项目,运行在ubuntu-latest上

我的 github 操作文件,

name: Testsuit

on:
  push:
    branches: [ main, dev ]
  pull_request:
    branches: [ main, dev ]

jobs:
  laravel-tests:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: …
Run Code Online (Sandbox Code Playgroud)

php github laravel github-actions

6
推荐指数
0
解决办法
937
查看次数

GitHub Actions 失败并出现 Gatsby 错误:输入文件包含不受支持的图像格式

我的网站使用 Gatsby 和 NetlifyCMS,目前在GitHub Actions运行工作流程时收到以下错误消息:

error "gatsby-plugin-manifest" threw an error while running the onPostBootstrap lifecycle:

Error: Input file contains unsupported image format
Run Code Online (Sandbox Code Playgroud)

很奇怪的是,在我的本地系统上使用gatsbydevelopgatsbybuild并没有出现该错误

我的插件数组如下所示:

plugins: [
    {
      resolve: `gatsby-plugin-typography`,
      options: {
        pathToConfigModule: `src/utils/typography`,
      },
    },
    {
      // keep as first gatsby-source-filesystem plugin for gatsby image support
      resolve: "gatsby-source-filesystem",
      options: {
        path: `${__dirname}/static/img`,
        name: "uploads",
      },
    },
    `gatsby-plugin-smoothscroll`,
    `gatsby-plugin-react-helmet`,
    `gatsby-plugin-twitter`,
    {
      resolve: "gatsby-plugin-netlify-cms",
      options: {
        modulePath: `${__dirname}/src/cms/cms.js`,
        htmlFavicon: `src/images/favicon.png`,
      },
    },
    `gatsby-plugin-no-index`,
    `gatsby-plugin-transition-link`, …
Run Code Online (Sandbox Code Playgroud)

gatsby netlify github-actions gatsby-image gatsby-plugin

6
推荐指数
1
解决办法
3052
查看次数

如何在 Github Action 中将配置参数添加到 postgres 服务容器?

我正在使用 Github Actions Service Container 来启动 postgres 实例,如下所示:

name: Pull Request

on:
  pull_request:
    branches:
      - main
      - staging

jobs:
  test-and-build:
    runs-on: ubuntu-latest

    services:
      redis:
        image: redis
        ports:
          - 6379:6379
      postgres:
        image: postgres
        env:
          POSTGRES_PASSWORD: postgres
        options: >-
          --health-cmd pg_isready
          --health-interval 10s
          --health-timeout 5s
          --health-retries 5
        ports:
          - 5432:5432

...
Run Code Online (Sandbox Code Playgroud)

这可行,但我想通过禁用 fsync 来加速 postgres 实例,如下所述:https://dev.to/thejessleigh/speed-up-your-postgresql-unit-tests-with-one-weird-trick-364p

当在 Docker 容器中本地运行 postgres 时,这会大大加快我的运行速度,我希望在 Github Actions 中做同样的事情,但我很难了解我如何配置图像。看来传递-c fsync=off到上面的选项块会导致错误:

Exit code 125 returned from process: file name '/usr/bin/docker', arguments 'create --name 04a7236d2e964fccb8a7d95684b3cf05_postgres_0249b3 --label …
Run Code Online (Sandbox Code Playgroud)

postgresql continuous-integration github docker github-actions

6
推荐指数
2
解决办法
2215
查看次数

错误:不允许应用具有 VCS 连接的工作区

Error: Apply not allowed for workspaces with a VCS connection
Run Code Online (Sandbox Code Playgroud)

我在尝试通过 Github Actions 应用 terraform 计划时收到此错误。

Github Action(地形应用)

- name: Terraform Apply Dev
  id: apply_dev
  if: github.ref == 'refs/heads/master' && github.event_name == 'push'
  run: TF_WORKSPACE=dev terraform apply -auto-approve deployment/
Run Code Online (Sandbox Code Playgroud)

Terraform 工作区 该工作区是在 Terraform Cloud 上创建的,Version control workflow称为app-infra-dev

地形后端

# The configuration for the `remote` backend.
terraform {
  backend "remote" {
    hostname = "app.terraform.io"
    organization = "my-org-name"
    workspaces {
      prefix = "app-infra-"
    }
  }
} 
Run Code Online (Sandbox Code Playgroud)

因此,因为我调用了我的工作区app-infra-dev,所以我在后端文件中的工作区前缀是在我的 …

terraform github-actions

6
推荐指数
1
解决办法
7548
查看次数