我在 GitHub 操作中设置了一个工作流来运行我的测试并创建测试覆盖的工件。我的 YAML 文件的精简版如下所示:
name: Build
on: [pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
# Other steps here
- name: Build app
- name: Run tests
- name: Create artifact of test coverage
# Other steps here
Run Code Online (Sandbox Code Playgroud)
问题是当测试失败时不会创建工件。
我if: always()从docs 中找出了条件,但这也会导致当我的Build app步骤失败时运行此步骤。我不希望这种情况发生,因为在这种情况下没有什么可存档的。
如果上一步已运行(成功或失败),我如何仅运行此步骤?
continuous-integration github continuous-deployment github-actions
我正在尝试通过GitHub 操作进行 maven 部署,但出现以下错误:-
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
gpg: no default secret key: No secret key
gpg: signing failed: No secret key
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.272 s
[INFO] Finished at: 2020-04-06T12:18:44Z
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-gpg-plugin:1.5:sign (sign-artifacts) on project pretty-simple-jar: Exit code: 2 -> [Help 1]
Run Code Online (Sandbox Code Playgroud)
我知道我需要以某种方式在运行操作工作流的虚拟运行器中导入我的 gpg 密钥,但我无法找到通过 GitHub 操作工作流在虚拟运行器中导入我的密钥的方法?
以下是我的工作流程:-
jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up …Run Code Online (Sandbox Code Playgroud) 我有一个带有 GitHub Action 的私有存储库,当有新的推送到主分支时,它会将代码推送到 AWS S3 存储桶。我需要一对访问密钥才能推送内容,我将它们存储为 GitHub Secrets 并将它们作为构建脚本中的环境变量进行引用。现在我想在不久的将来公开这个 repo,我想知道这样做是否安全。操作的工作流 (.github/workflows/main.yml) 本身确实是公开可见的,它的作用是什么,但它只有一个命令aws s3 cp myfile s3://my-bucket,代码本身绝对没有访问密钥。
将 GitHub Secrets 用于公共存储库中的操作是否安全?我是唯一的所有者和唯一的贡献者,这在未来不会改变。稍后我可能会使用 webhook 切换到 CodePipeline,但想先尝试 GitHub Actions。谢谢。
我在 GitHub 上做了一个新项目,有两个工作流程:
我希望只有在第一个工作流程成功时才触发第二个工作流程。有没有办法做到这一点?或者我是否需要创建一个工作流文件,其中第二个工作依赖于第一个工作?
我想在我的 Github 操作工作流中的作业之间定义和设置环境变量。下面的工作流程是我尝试过的,但不幸的是环境变量GIT_PR_SHA_SHORT和E2E_GIT_PR_SHA不起作用。
是否可以?
name: Git Pull Request Workflow
on:
workflow_dispatch:
pull_request:
branches:
- master
env:
GIT_PR_SHA: ${{github.event.pull_request.head.sha}}
GIT_PR_SHA_SHORT: "${{ env.GIT_PR_SHA:0:10 }}"
ENV_NAME: test
E2E_GIT_PR_SHA: "${{ env.ENV_NAME }}-${{ env.GIT_PR_SHA_SHORT }}"
jobs:
first-job:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: First Echo Step
run: |
echo "GIT_PR_SHA_SHORT = ${GIT_PR_SHA_SHORT}"
echo "E2E_GIT_PR_SHA = ${E2E_GIT_PR_SHA}"
second-job:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Second Echo Step
run: |
echo "GIT_PR_SHA_SHORT = ${GIT_PR_SHA_SHORT}"
echo "E2E_GIT_PR_SHA = …Run Code Online (Sandbox Code Playgroud) 我正在使用 GitHub 操作配置工作服。
我进行了搜索,但找不到如何生成 ./coverage/lcov.info 文件。
当操作运行时,由于我没有这样的文件,我得到:
Using lcov file: ./coverage/lcov.info
Error: Lcov file not found.
Run Code Online (Sandbox Code Playgroud)
我尝试通过 IntelliJ 使用 Coverage 运行测试,但我可以生成的唯一导出是 HTML 格式。
如何生成 lcov.info 文件?
编辑 - 根据评论中的要求添加我的工作流程以供参考
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
name: "CodeQL"
on:
push:
branches: …Run Code Online (Sandbox Code Playgroud) 我有一个跨平台项目,要在两个平台上构建:mac 和 linux(ubuntu)。
我的管道包含 3 个作业:
linux和macos的步骤绝对是一样的。但矩阵有很大不同,Linux 构建是在容器内运行的。
有没有办法在两个不同的工作之间共享步骤?
我尝试了 YAML 锚点,但 GitHub 不支持它们。
完整的工作流程
on:
push:
branches: [ main, support/1.2.x ]
pull_request:
branches: [ main, support/1.2.x ]
jobs:
Docker-iroha-builder:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
-
name: Cache Docker layers
uses: actions/cache@v2
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- …Run Code Online (Sandbox Code Playgroud) 我试图在成功运行不同的操作后触发 Github 操作来运行。
这两个工作流程是:
单元测试操作(首先运行,并且应该触发下面的“后续测试”操作
name: unit-tests
on:
push:
branches:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: "3.1.x"
- name: Test
run: dotnet test src/XXXXXXXXXX
Run Code Online (Sandbox Code Playgroud)
遵循测试操作(这只是一个测试操作)
name: Test action triggered by previous action success
on:
workflow_run:
workflows:
- unit-tests
types:
- completed
jobs:
test-job:
name: Test Step
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.event.workflow_run.head_branch }}
- run: echo "The follow on works!!"
Run Code Online (Sandbox Code Playgroud)
问题是,当这是在功能分支而不是默认分支上触发时(因为我希望操作运行所有分支),它不起作用? …
continuous-integration github continuous-deployment github-actions
这是我的 GitHub Action 步骤。PRIVATE_REQUIREMENT_OWNER_TOKENSecret 已创建并包含具有完整repo范围的 GitHub 令牌:
- name: Build docker image
id: docker_build
uses: docker/build-push-action@v2
with:
push: false
context: .
tags: 'username/image:latest'
secrets: |
"github_token=${{ secrets.PRIVATE_REQUIREMENT_OWNER_TOKEN }}"
Run Code Online (Sandbox Code Playgroud)
这是requirements.txt 中的一行,其中包含指向私有存储库的链接,并在上述步骤中从 Dockerfile 构建 docker 映像时尝试安装:
git+ssh://git@github.com/username/private-repository
Run Code Online (Sandbox Code Playgroud)
该行已添加到Dockerfile
RUN --mount=type=secret,id=github_token pip install https://$(cat /run/secrets/github_token)@github.com/username/private-repository.git
Run Code Online (Sandbox Code Playgroud)
这会在 GitHub Actions 中引发以下错误:
#11 [ 6/12] RUN --mount=type=secret,id=PRIVATE_REQUIREMENT_OWNER_TOKEN_SECRET pip install https://$(cat /run/secrets/PRIVATE_REQUIREMENT_OWNER_TOKEN_SECRET)@github.com/username/private-repository.git
#11 sha256:b3d88dd9813db3257b15f53f1eb5a4c593c69ff98ec03cc4d70d564df1a1f7f6
#11 0.697 Collecting https://****@github.com/vassilyvv/django-sinbad.git
#11 0.790 ERROR: HTTP error 404 while getting https://****@github.com/username/private-repository
.git
#11 0.791 ERROR: Could …Run Code Online (Sandbox Code Playgroud) 我在 GitHub actions 上有以下工作。我想跳过 macOS x86 配置:有办法做到这一点吗?
build-and-push-native-libraries:
name: Build and push native library on ${{ matrix.os }} ${{ matrix.architecture }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macOS, windows-latest]
java: [15]
architecture: [x86, x64]
include:
- compiler: gcc
gcc: 8
runs-on: ${{ matrix.os }}
steps:
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
architecture: ${{ matrix.architecture }}
- uses: actions/checkout@v2
- if: startsWith(matrix.os, 'ubuntu') == true
name: Change the permissions of the build …Run Code Online (Sandbox Code Playgroud) github-actions ×10
github ×4
docker ×2
coveralls ×1
dependencies ×1
dockerfile ×1
git ×1
gnupg ×1
java ×1
jobs ×1
publish ×1
workflow ×1
yaml ×1