标签: github-actions

如何在github动作中获取当前分支

我正在使用Github Actions构建docker映像,并想用分支名称标记映像,我只找到了GITHUB_REF变量,但结果是refs/heads/feature-branch-1,我只需要feature-branch-1

github github-actions

7
推荐指数
16
解决办法
1306
查看次数

如果你使用 GitHub actions 的矩阵策略,那么运行 tox 不是多余的吗?

使用 GitHub actions 矩阵策略,您可以指定您希望代码运行的 python 版本(例如),那么是否需要在 GitHub actions 工作流程中运行 tox?

是否有任何毒素提供了 gh 行动矩阵策略所没有的东西?

谢谢!

tox github-actions

7
推荐指数
1
解决办法
809
查看次数

如何从 GitHub 检查中删除 Azure Pipeline Build

我刚刚为 GitHub 存储库设置了 CI/CD。

  • 验证拉取请求的 CI 构建被设置为 GitHub Action。
  • CD 构建(应在合并拉取请求后运行)是使用 Azure Pipelines 设置的,因为我也想使用生成的工件作为使用 Azure Pipelines 的发布管道的触发器。

唯一仍然困扰我的是,CD 构建也会自动触发拉取请求,但我不知道在哪里可以配置这些检查。

创建拉取请求时当前运行的检查如下: 在此输入图像描述

我想在这里摆脱持续交付构建。

我尝试配置分支保护规则,但这没有效果: 在此输入图像描述

在Azure Pipeline端,我完全禁用了触发器: 在此输入图像描述 在此输入图像描述

但这对我来说也没有明显的影响。

continuous-integration continuous-deployment azure-pipelines github-actions

7
推荐指数
1
解决办法
2587
查看次数

Google Cloud Build/GitHub 中出现无效参数错误

我一直在尝试将 Google Cloud Build 与我的 GitHub 帐户集成。我过去曾为 GCP 上的其他项目设置过工作构建触发器 - 但对于这个,我无法让它可靠地工作。这是我所做的:

  1. 在 GitHub 上安装 Google Cloud Build 应用程序并将其链接到我的 Google Cloud 帐户。
  2. 连接到我在 Google Cloud Build 中的 GitHub 存储库。作为来源,我选择了“GitHub(Cloud Build GitHub App)”。
  3. 让 Cloud Build 为我创建默认触发器 - 只是为了确保设置正确。

现在,当手动运行默认触发器时,在选择分支后我总是收到以下错误消息:“无法触发构建:请求包含无效参数。” 看起来是这样的:

Google Cloud Build 上的无效参数错误

当通过 GitHub 存储库中的新提交调用时,触发器也不起作用。我通过 GitHub UI 发现了两个不同的错误:

  1. 当手动调用构建并立即失败时,GitHub Cloud Build Action 基本上会报告与 Cloud Build 本身相同的错误:

GitHub 错误 1

  1. GitHub Cloud Build Action 已排队/启动,但实际上从未执行任何操作。在这种情况下,Cloud Build 似乎甚至不知道 GitHub 触发的构建。尽管默认情况下 Cloud Build 通常会在 10 分钟后取消构建,但该操作仍将保持此状态数小时。

GitHub 错误 2

到目前为止,我已经尝试过以下一些措施来缓解该问题:

  • 创建各种不同的触发变化 - 它们似乎都不起作用。错误总是一样的。
  • 在 Github 上卸载 Cloud Build 应用程序,取消链接我的 Google Cloud 帐户,然后再次完成整个设置过程。 …

github google-cloud-platform google-cloud-build github-actions

7
推荐指数
1
解决办法
7455
查看次数

是否可以直接下载 Github-Actions 工件?

当我想要下载工件时,我使用以下类型的 URL:https://github.com/some_user/some_repo/suites/some_id/artifacts/some_id.zip然而,即使结果只是一个文件,这也总是引导我找到一个包。就我而言,这个附加层完全是多余的,我想跳过它(当我构建一个我希望能够方便预览的 pdf 时,这尤其烦人)。

(如何)我可以设置自动化工作流程来公开解压的文件吗?

github artifact github-actions

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

如何在 GitHub 操作中为 Docker 构建和发布设置正确的工作目录?

我有这个 GitHub 操作作业来构建 Docker 映像并将其发布到 GitHub 注册表。

...
jobs:
  push_to_registry:
    name: Push Docker image to GitHub Packages
    runs-on: ubuntu-latest
    steps:
      - name: Check out the repo
        uses: actions/checkout@v2
      - name: Push to GitHub Packages
        uses: docker/build-push-action@v1
        with:
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}
          dockerfile: Dockerfile
          registry: docker.pkg.github.com
          repository: myrepo/myimg
          tag_with_ref: true
Run Code Online (Sandbox Code Playgroud)

但是它在父目录中运行,而我Dockerfile的在里面app/

.
|- .github/workflow/ci.yaml
|- README
|- app/
   |- Dockerfile
   |- package.json
   |- package.lock.json
   |- node_modules/
   |- src/
   |- ...
Run Code Online (Sandbox Code Playgroud)

我尝试设置working-directory: …

github docker dockerfile github-actions

7
推荐指数
1
解决办法
9798
查看次数

Github Actions:尽管已安装,但未找到 xcpretty

我正在尝试用 Github Actions 取代我们 iOS 项目糟糕的 Jenkins 设置。我想我已经准备好了所有的部分,但我遇到了一个我不明白的失败。在我运行构建和测试应用程序的步骤中xcodebuild,我收到了一个xcpretty未知命令的错误,尽管在上一步中是通过捆绑程序安装的。以下是相关文件:

构建并运行.yml

---
name: Build & Test
on:
  # Run tests when a PR merges.
  push:
    branches:
      - develop

  # Run tests when PRs are created or updated.
  pull_request:
    types: [opened, synchronize, reopened]

  # Allow the workflow to be run manually.
  workflow_dispatch:

env:
  DEVELOPER_DIR: /Applications/Xcode_12.app/Contents/Developer

jobs:
  test:
    name: Build & Test
    runs-on: 'macos-latest'

    steps:
      - name: Checkout Project
        uses: actions/checkout@v2
        with:
          ref: develop

      - name: Setup Ruby
        uses: ruby/setup-ruby@v1.46.0 …
Run Code Online (Sandbox Code Playgroud)

rubygems xcodebuild ios github-actions

7
推荐指数
1
解决办法
3245
查看次数

如何在github Action中传递json文件?

我正在尝试创建网络流程以在 Play 商店上发布应用程序。

这是代码:

- name: Upload to Google Play
        uses: r0adkll/upload-google-play@v1
        with:
          serviceAccountJson: ${{ SERVICE_ACCOUNT_JSON }}
          packageName: packagename
          releaseFile: app/release/app.aab
          track: internal
          whatsNewDirectory: distribution/whatsnew
Run Code Online (Sandbox Code Playgroud)

但无法理解如何在 serviceAccountJson 键处传递 JSON 服务帐户文件位置?

我需要将文件存储在本地并传递路径还是需要将文件添加到Github Secret中?

github google-play google-play-developer-api google-play-console github-actions

7
推荐指数
1
解决办法
4543
查看次数

避免 GitHub 操作缓冲

我有一个 Github 存储库,其中包含一些 Linux 实用程序。

为了运行测试,我使用 GitHub 操作和一些简单的自定义工作流程,这些工作流程使用自托管运行器在远程 Linux 服务器上运行:

name: CMake
on: [push]
env:  
  BUILD_TYPE: Release
jobs:
  build:
    runs-on: self-hosted
    steps:
    - uses: actions/checkout@v2
    - name: Build
      working-directory: ${{runner.workspace}}/Utils
      shell: bash
      run: cmake --build . --config $BUILD_TYPE

    - name: Run test
      working-directory: ${{runner.workspace}}/Utils
      shell: bash
      run: ./testing/test.sh
Run Code Online (Sandbox Code Playgroud)

工作流程非常简单 - 我使用编译源代码cmake,然后运行来自同一存储库的脚本来测试构建。测试脚本是一个 bash 脚本,如下所示:

#!/bin/bash

export LD_LIBRARY_PATH=/path/to/bin

cd /path/to/bin

echo -e "Starting the tests"

./run_server &
./run_tests

if [ $? -eq 0 ]; then
    echo "successful"
else
    echo "failed" …
Run Code Online (Sandbox Code Playgroud)

github github-actions

7
推荐指数
0
解决办法
492
查看次数

如何将 terraform 状态集成到 github 操作工作流程中?

我有 github 操作工作流程,概述了启动 terraform 以在 Azure 中创建资源的简单过程。我缺少的是如何集成 terraform 状态文件,以便在顺序运行此工作流程时,它应该将当前状态与 main.tf 文件进行比较,并且只允许净更改。目前,如果我按顺序运行此命令,第二次总是会失败,因为资源已经在 Azure 中创建。

如何配置下面的 github 工作流程以允许 terraform 状态文件比较?,我还没有找到执行此操作的单个来源

github 仓库布局: 在此输入图像描述

github操作工作流程:

name: Terraform deploy to Azur

on: [push]

jobs:
  build:
    runs-on: ubuntu-latest
    
    steps:
    - name: "Checkout"
      uses: actions/checkout@master
      
    - name: "Terraform Init"
      uses: hashicorp/terraform-github-actions@master
      with:
       tf_actions_version: 0.12.13
       tf_actions_subcommand: "init"

    - name: "Terraform Plan"
      uses: hashicorp/terraform-github-actions@master
      with:
       tf_actions_version: 0.12.13
       tf_actions_subcommand: "plan"
       args: -var="client_secret=${{ secrets.clientSecret }}"
             -var="client_id=${{ secrets.clientId }}"
             -var="tenant_id=${{ secrets.tenantId }}"
             -var="sub=${{ secrets.sub }}"
                  
    - name: "Terraform Apply"
      uses: hashicorp/terraform-github-actions@master
      with: …
Run Code Online (Sandbox Code Playgroud)

terraform terraform-provider-azure github-actions

7
推荐指数
1
解决办法
9952
查看次数