标签: github-actions

为什么我在此 GitHub 操作中收到“Unexpected value ''”错误?

我有一个像这样的 GitHub 操作步骤(从较大的文件中提取test.yml):

    steps:
    - name: Parse
      shell: bash
      env:
        TYPE: ${{matrix.package-type}}
        BV: ${{matrix.builder-version}}
        # This comment is line 63, the "#" is in column 9
        NULL: ${{ matrix.beta-version }}
      run: |
        echo TYPE is "$TYPE"
        echo BV is "$BV"
        printf "Null is '%s'\n" "$NULL"
Run Code Online (Sandbox Code Playgroud)

当我运行它时,我收到以下错误:

The workflow is not valid. .github/workflows/test.yml (Line: 64, Col: 9): Unexpected value ''
Run Code Online (Sandbox Code Playgroud)

为什么这一行无效?我如何解决它?

github-actions

10
推荐指数
2
解决办法
2万
查看次数

Github 操作如何从变量中删除起始“v”

我有一个在发布事件上发布 nuget 包的工作流程,但我无法从标记名中删除“v”字符。我所有的标签名称都是 v${version} 所以我需要删除该“v”并仅获取版本。

我的工作流程是这样的:

name: Nuget package publish

on:
  release:
    types: [published]

jobs:

  nuget:
    name: Nuget - Publish package
    runs-on: ubuntu-latest
    timeout-minutes: 15
    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Verify commit exists in origin/master
        run: |
          git fetch --no-tags --prune --depth=1 origin +refs/heads/*:refs/remotes/origin/*
          git branch --remote --contains | grep origin/master
      - name: Set VERSION variable from tag
        run: | 
          echo "VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV
          echo "VERSION=${VERSION:1}" >> $GITHUB_ENV
      - name: Build
        run: dotnet build --configuration …
Run Code Online (Sandbox Code Playgroud)

github-actions

10
推荐指数
3
解决办法
6404
查看次数

从 Github 存储库创建公开分发的 Jupyter Notebook

我有一个在线课程(Performance Ninja),我想将其变成公开分发的 Jupyter Notebook。该课程托管在 Github 上。那里有学生需要完成的实验室作业的源代码。他们需要通过更改代码并提交(git Push)他们的工作来解决问题。它将被 Github Actions 拾取并发送到我的远程服务器,该服务器已针对性能基准测试进行了适当配置。因此,我不依赖 Github 提供的虚拟化 CI 机器,例如它们不适合性能测量。

\n

我想制作一个 Jupyter Notebook,它将作为我的 Github 存储库的视图。它将提供漂亮的界面,能够专注于重要的代码部分(基准测试的内核),并且有一种简单的方法来提交自动基准测试的解决方案(只需按 Shift-Enter)。

\n

我正在查看 JupyterHub。它应该可以很好地工作,但问题是我必须为 JupyterHub 服务器拥有一个公共静态 IP。

\n

理想情况下,我希望能够从 Jupyter Notebook 本身触发 Github Actions 工作流程。用户(学生)将通过 Github 验证自己的身份,更改代码并按 Shift-Enter,这将触发 Github 操作(可能将代码推送到私有分支)。

\n

我假设我\xe2\x80\x99m 不是第一个面临类似问题的人。我想听听有经验的人的意见,我在这里最好的选择是什么?

\n

jupyter-notebook jupyterhub github-actions

10
推荐指数
0
解决办法
430
查看次数

无法使用 github actions 发布 npm 包

我正在尝试通过 github 操作在 github 注册和 npm 注册上发布我的 npm 包。github 上的一个成功,但另一个失败了,原因如下:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com/nullndr
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)

为什么我需要npm adduser。我使用自动化令牌,这还不够吗?

这是我的工作流程文件:

npm ERR! code ENEEDAUTH
npm ERR! need auth This command requires you to be logged in to https://npm.pkg.github.com/nullndr
npm ERR! need auth You need to authorize this machine using `npm adduser`
Run Code Online (Sandbox Code Playgroud)

我缺少什么?

npm github-actions

10
推荐指数
1
解决办法
2182
查看次数

ERROR Backend subproccess exited when trying to invoke get_requires_for_build_sdist

I used the Upload Python Package workflow on GitHub to upload the module stored in the repository to PyPI.

As you can see at the link above, I followed the tutorial given by packaging.python.org, to be more specific I used setup.py instead of setup.cfg.


Anyway an error occurred during the last deploy, which gave me the following error:

Run python -m build
      python -m build
      shell: /usr/bin/bash -e {0}
      env:
        pythonLocation: /opt/hostedtoolcache/Python/3.10.4/x64
        LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.10.4/x64/lib
    running egg_info …
Run Code Online (Sandbox Code Playgroud)

python pip package pypi github-actions

10
推荐指数
1
解决办法
2万
查看次数

是否可以使用 github 可重用工作流的子文件夹?

我要创建一个可重用(“称为”)GitHub 工作流程,并希望将其存储在单独的文件夹中,例如“.github/workflows/public”,但收到错误“缺少可重用工作流程的完整路径”在调用者工作流程文件中。GitHub 是否限制工作流程只能存储在“.github/workflows”文件夹中?

github github-actions

10
推荐指数
1
解决办法
5875
查看次数

GitHub Actions 检查空调度输入

我有一个由带有一些非必需字符串输入的事件触发的工作流程workflow_dispatch,并且正在尝试找出如何确定是否提供了该值。

on:
  workflow_dispatch:
    inputs:
      input1:
        description: first input
        required: false
        type: string
      input2:
        description: second input
        required: false
        type: string
Run Code Online (Sandbox Code Playgroud)

该文档表示,类型的未设置输入string将等同于工作流程中的空字符串,但是当我在作业的if子句条件中检查该输入时,它似乎没有正确评估。

jobs:
  jobA:
    if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.input1 != '' }}
    # ...
Run Code Online (Sandbox Code Playgroud)

即使当我在输入为空的情况下分派工作流时,这两个步骤都会运行。

如果不是的话,检查输入值是否未设置的惯用方法是什么?

github-actions

10
推荐指数
1
解决办法
2万
查看次数

在列表中运行的 Github 操作的名称

我有一个设置名称并在拉取请求上运行的 Github 操作:

\n
name: Code Quality\non:\n  workflow_dispatch:\n  pull_request:\n    branches: [ main, develop ]\n
Run Code Online (Sandbox Code Playgroud)\n

当我手动触发运行时(因为workflow_dispatch也设置了),运行将在运行列表中获得标题 \xe2\x80\x9cCode Quality\xe2\x80\x9d 。

\n

但是,当针对拉取请求运行该操作时,列表中的运行名称将设置为 PR 的名称。这可能是也可能不是一个好标题,很大程度上取决于 PR\xe2\x80\x99s 作者。有没有办法影响列表中操作的标题?

\n

github-actions

10
推荐指数
1
解决办法
8333
查看次数

GitHub Actions:我可以动态生成并运行子工作流程吗?

我们正在从 gitlab 迁移到 github。

使用 gitlab pipelines,我检查存储库并动态生成一个包含要运行的实际作业的子管道。通过实际定义最容易解释这一点:

stages:
    - bootstrap
    - run


    
# ---------------------------------------------------------------------------
# Bootstrap
# ---------------------------------------------------------------------------

bootstrap:
    stage: bootstrap
    # this will write the file jobs.yml to disk
    script: ./bootstrap.ps1

    artifacts:
        paths:
            - artifacts/jobs.yml



# ---------------------------------------------------------------------------
# Run
# ---------------------------------------------------------------------------

run:
    stage: run
    trigger:
        include:
            - artifact: artifacts/jobs.yml
              job: bootstrap
        strategy: depend
Run Code Online (Sandbox Code Playgroud)

github actions 有类似的吗?我发现可以动态生成矩阵,但这还不够。

我需要运行相互依赖并并行/顺序运行的作业。

例子:

在此输入图像描述

整个作业图是动态生成的。

在这里,我有三个阶段,所有应用程序作业并行运行,并且单个部署作业等待所有应用程序作业完成。

我还需要将应用程序作业的输出传递到部署作业,这似乎也不能真正使用矩阵:https ://github.com/github-community/community/discussions/17245

即使输出由作业的多个矩阵变体设置,也只保留一个。


那么,实际的问题是有没有一种方法可以动态生成具有多个相互依赖的作业的工作流程并执行它,或者这是不存在的东西?

gitlab-ci github-actions

10
推荐指数
1
解决办法
1175
查看次数

如果在github操作中传递的参数为空,如何保留默认操作输入

我有一个工作流程,workflow_dispatch输入默认为空字符串。该工作流程使用本地 github 操作,其自定义输入及其各自的默认值:

# .github/workflow/ci.yml
on:
  push:
    - main
    - wip/**

  workflow_dispatch:
    inputs:
      myInput:
        description: An input string
        type: string

jobs:
  myJob:
    steps:
      - name: My action step
        uses: ./.github/actions/my-action
        with:
          myInput: ${{ github.event.inputs.myInput }}
Run Code Online (Sandbox Code Playgroud)
# .github/actions/my-action/action.yml
name: 'My action'
description: 'An action'
inputs:
  myInput:
    description: An input
    required: false
    default: 'My default input'

runs:
  steps:
    - name: Run
      shell: bash
      run: echo Input: ${{ inputs.myInput }}
Run Code Online (Sandbox Code Playgroud)

如果工作流程是由推送触发的,或者如果我使用空输入手动启动工作流程,我希望该操作my-action保留其默认输入值My default input而不是空字符串。

您知道这是否可以从工作流程中实现,而无需调整my-action操作吗?

github github-actions

10
推荐指数
0
解决办法
6611
查看次数