标签: building-github-actions

GitHub 工作流程输入参数的下拉列表

我想为我的 GitHub 操作输入参数创建一个下拉列表。这应该有助于从下拉列表中选择一个值,就像选项如何选择分支一样。

github-api github-actions building-github-actions

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

从 GitHub 操作推送到源

我正在尝试origin从 GitHub 操作推送到远程。我的行动逻辑是:

  • 处理pull_request_review事件并按评论消息过滤
  • checkout to master, merge PR branch, run some checks and push it to origin

The script is:

if [[ "${GITHUB_EVENT_NAME}" != "pull_request_review" ]]; then
  echo "unsupported event: ${GITHUB_EVENT_NAME}"
  exit 1
fi

user=$(jq -r .review.user.login ${GITHUB_EVENT_PATH})
cmd=$(jq -r .review.body ${GITHUB_EVENT_PATH})
echo "reviewer is ${user}, command is ${cmd}"

if [[ "${cmd}" == "merge" ]]; then
  head=$(jq -r .pull_request.head.ref ${GITHUB_EVENT_PATH})
  git config user.email test@test.com
  git config user.name test
  git checkout -B _tmp origin/${head}
  git checkout …
Run Code Online (Sandbox Code Playgroud)

git github docker github-actions building-github-actions

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

GitHub Actions:缺少必需的属性:shell

介绍

我目前正在创建一个复合 GitHub Actions,它从 Java 项目构建 JavaDoc,并使用 GitHub Page 自动将其发布到静态页面。

有问题的

但是当我尝试运行它时出现此错误:

Current runner version: '2.287.1'
Operating System
Virtual Environment
Virtual Environment Provisioner
GITHUB_TOKEN Permissions
Secret source: Actions
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'MathieuSoysal/Javadoc-publisher.yml@v2.0.2' (SHA:878c07f835dd9bcbb8800090d109c91b0f0d4581)
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property is missing: shell
Error: GitHub.DistributedTask.ObjectTemplating.TemplateValidationException: The template is not valid. MathieuSoysal/Javadoc-publisher.yml/v2.0.2/action.yml (Line: 29, Col: 5): Required property …
Run Code Online (Sandbox Code Playgroud)

java javadoc maven github-actions building-github-actions

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

如何在工作流程中使用 Github 操作的输出?

让我们以 Github 文档中的复合操作为例:

name: 'Hello World'
description: 'Greet someone'
inputs:
  who-to-greet:  # id of input
    description: 'Who to greet'
    required: true
    default: 'World'
outputs:
  random-number:
    description: "Random number"
    value: ${{ steps.random-number-generator.outputs.random-id }}
runs:
  using: "composite"
  steps:
    - run: echo Hello ${{ inputs.who-to-greet }}.
      shell: bash
    - id: random-number-generator
      run: echo "::set-output name=random-id::$(echo $RANDOM)"
      shell: bash
    - run: ${{ github.action_path }}/goodbye.sh
      shell: bash
Run Code Online (Sandbox Code Playgroud)

我们如何random-number在调用此操作的外部工作流程中使用该特定输出?我尝试了以下代码片段,但目前工作流程似乎无法从操作中读取输出变量,因为它只是空的 - '输出 - '


jobs:
  test-job:
    runs-on: self-hosted
    steps:
      - name: Call Hello …
Run Code Online (Sandbox Code Playgroud)

github-actions building-github-actions

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

github actions 中的环境变量

我想将 Maven 图像版本作为 env 变量传递,但是当我尝试访问该 env.MAVEN_VERSION 变量时出现错误

错误 - 工作流程无效。.github/workflows/Merge.yaml(第 13 行图像:)无法识别的命名值:“env”。位于表达式中的位置 1:env.MAVEN_VERSION

Yaml 文件 ---

on:
  push:
    branches: [ master ]

env:
  MAVEN_VERSION: maven:3.8.6-jdk-11
  
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: ${{ env.MAVEN_VERSION }}
    steps:
    - name: Env Variable
      run: echo ${{ env.MAVEN_VERSION }}
Run Code Online (Sandbox Code Playgroud)

github environment-variables github-actions building-github-actions

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

在 GitHub Action 中,如何根据上一步的输出来条件化步骤?

基于提交消息构建 GitHub 操作 我尝试根据提交消息是否包含特定字符串来制定步骤,将其设置为变量,然后在下一步中检查条件。

我目前的行动实施有效:

name: Smoke Test
on:
  push:
    branches:
      - main

permissions:
  contents: read
  issues: write

jobs:
  smoking:
    runs-on: [ubuntu-latest]
    steps:
      - name: Run smoke tests
        if: ${{ !contains(github.event.head_commit.message, 'smoke_test') }}
        run: |
          echo 'Smoke Test not requested'
          exit 1
  stuff:
    needs: smoking
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: JasonEtco/create-an-issue@v2
        env:
          GITHUB_TOKEN: ${{ secrets.TOKEN }}
        with:
          filename: .github/ISSUE_TEMPLATE/smoke-test.md
        id: create-issue
      - run: 'echo Created issue number ${{ steps.create-issue.outputs.number }}'
      - run: 'echo Created ${{ steps.create-issue.outputs.url }}' …
Run Code Online (Sandbox Code Playgroud)

github github-actions building-github-actions

14
推荐指数
1
解决办法
3万
查看次数

如何在 github 操作条件中检查标签

假设我有一个这样的 github 操作:

name: My Action

on:
  pull_request:
    types:
      - closed

jobs:
  myjob:
    runs-on: ubuntu-latest
    name: Test
    if: github.event.pull_request.merged && XXX
Run Code Online (Sandbox Code Playgroud)

我想在这里有一个条件来测试标签的存在。

docs, usingcontains( github.event.pull_request.labels, 'my_label')似乎不合适,因为它是字典而不是数组。

有没有办法解决?

github-actions building-github-actions

13
推荐指数
1
解决办法
2773
查看次数

禁用 Github Action 工作流程,仅在需要时运行

我有一些非常昂贵的基准/测试,我只想在一些 PR 上运行,而不是全部。有没有办法通过 github actions 来做到这一点?

continuous-integration github github-actions building-github-actions

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

如何知道要使用哪个版本的 GitHub Action

我在各种 GitHub Action 工作流程示例中注意到,通常在调用预定义操作(使用语法uses:)时,会指定该操作的特定版本。例如:

steps:
    - uses: actions/checkout@v2
    - name: Set up Python
      uses: actions/setup-python@v2
      with:
        python-version: '3.x'
Run Code Online (Sandbox Code Playgroud)

上述工作流程指定了@v2actions/checkoutactions/setup-python

问题是,如何知道哪个版本@v2是最好使用的版本?
我如何知道何时@v3可用?

更令人困惑的是用于发布到pypi 的pypa/gh-action-pypi-publish操作的情况。在我看过的示例中,我至少看到指定了四个不同的版本:

  • pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
  • pypa/gh-action-pypi-publish@master
  • pypa/gh-action-pypi-publish@v1
  • pypa/gh-action-pypi-publish@release/v1

我怎么知道该使用哪一个? 一般来说,您如何知道哪些可用,以及它们之间的差异是什么?

python github-actions building-github-actions

13
推荐指数
1
解决办法
5460
查看次数

如何查明触发当前工作流程的 Github Actions 事件是否是新的拉取请求?

我有一个启动的 Github Actions 工作流程:

on:
  pull_request:
    types:
      - synchronize
      - opened
Run Code Online (Sandbox Code Playgroud)

运行我的自定义操作:

jobs:
  my_job:
    uses: "org/repo/.github/workflows/main.yml@master"
Run Code Online (Sandbox Code Playgroud)

在操作中org/repo,我想在打开拉取请求时执行额外的操作,但不在同步时执行。所以我这样org/repo/.github/workflows/main.yml做:

- if: ${{ condition }}
  name: Do that additional thing
Run Code Online (Sandbox Code Playgroud)

应该如何condition区分新打开的拉取请求事件和“同步”事件(推送新提交等)?我想这将涉及检查一些内容,但我在文档${{ github.event.pull_request }}中找不到它。

github-actions building-github-actions github-actions-workflows

12
推荐指数
1
解决办法
6347
查看次数