我在尝试启动 Github 操作工作流程时陷入困境。Flutter项目有一个自定义包的依赖。我在 Github 存储库中有这个自定义包。这是我在 pubspec.yaml 中设置此依赖项的方式:
xxxx_package:
git:
url: git@github.com:USER_NAME/xxxx_package.git
ref: develop
Run Code Online (Sandbox Code Playgroud)
如果我启动flutter pub get命令,它就会成功结束,我可以毫无问题地构建和执行应用程序。
但是当我向 Github 发送推送并启动工作流程时,该过程结束时出现以下错误:
Running "flutter pub get" in Project-Flutter...
Git error. Command: `git clone --mirror git@github.com:xxx/xxxx_package.git /home/runner/.pub-cache/git/cache/xxxx_package-123456789`
stdout:
stderr: Cloning into bare repository '/home/runner/.pub-cache/git/cache/xxxx_package-123456789'...
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Run Code Online (Sandbox Code Playgroud)
这是我的操作工作流程文件:
name: Check merge
on:
push:
branches: [ main, develop ]
pull_request:
branches: [main, develop]
workflow_dispatch:
jobs:
build:
name: flutter environment
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2 …Run Code Online (Sandbox Code Playgroud) 在推送事件中,是否可以获得 PR 标题,以便我可以使用相同的内容来创建版本和标签。
目前,我无法在推送事件中获得 PR 头衔。
任何人都可以帮忙吗?
我第一次使用 tflint 扫描我的 terraform 代码。为此,我创建了 shell 脚本来执行 tflint 命令,但是,在执行 tflint 作业时,我收到一些 [WARN] 消息。我不确定它们是如何生成的。有办法抑制吗?
tflint 命令已成功执行,并且还在我的 terraform 代码中显示可能的问题/通知。
我正在使用下面的 Github 工作流程操作;
- name: Setup TFLint
uses: terraform-linters/setup-tflint@v1
with:
tflint_version: v0.26.0
- name: Lint Terraform Code
run: scripts/tflint.sh
shell: bash
continue-on-error: false
Run Code Online (Sandbox Code Playgroud)
“.tflint.hcl”文件 ->
plugin "aws" {
enabled = true
version = "0.12.0"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
rule "terraform_naming_convention" {
enabled = true
}
rule "terraform_unused_declarations" {
enabled = true
}
rule "terraform_deprecated_index" {
enabled = true
}
rule "terraform_documented_outputs" {
enabled …Run Code Online (Sandbox Code Playgroud) Nextjs 的 GitHub Actions 构建失败,我有以下 GitHub 工作流程文件:
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out …Run Code Online (Sandbox Code Playgroud) 我正在尝试从 ECR 中提取 docker 映像并将其部署到 ec2 实例上。然而它抛出了一个错误,比如
docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
======END======
err: invalid reference format
2022/11/03 15:31:54 Process exited with status 1
Run Code Online (Sandbox Code Playgroud)
我的 yml 文件是:
name: Docker Image CI
on:
push:
branches: [ "main" ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.TF_USER_AWS_KEY }}
aws-secret-access-key: ${{ secrets.TF_USER_AWS_SECRET }}
aws-region: us-east-1
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v1
- name: Build, tag, and push image to Amazon …Run Code Online (Sandbox Code Playgroud) 对于这个问题,有几个限制:
core.setOutput(name, value);console.log(`::set-output name=${key}::${value}`);。正如本博客文章中所宣布的,此方法已被弃用。根据博客推荐的新方法是写入新的 $GITHUB_OUTPUT 环境文件。不幸的是,博客文章中没有 JavaScript 示例。
简单的实现是运行:
fs.writeFileSync(process.env.GITHUB_OUTPUT, `${key}=${value}`);
Run Code Online (Sandbox Code Playgroud)
是否有更简单、更好或推荐的方法在 JavaScript 中实现此功能?
我尝试过了console.log(`::set-output name=${key}::${value}`);。正如本博客文章中所宣布的,此方法已被弃用。
您可以使用 jobs.<job_id>.concurrency 确保一次仅运行一个使用相同并发组的作业或工作流。
...
当并发作业或工作流排队时,如果使用存储库中相同并发组的另一个作业或工作流正在进行中,则排队的作业或工作流将处于挂起状态。并发组中任何先前挂起的作业或工作流都将被取消。
以前待处理的作业被取消是很烦人的。显然,编排逻辑只能维护一(1)个待处理作业的微小“队列”。
我希望能够有多个作业排队。即,如果我快速连续触发 5 个作业,并且它们都属于同一个并发组,则第一个作业立即开始运行(当运行程序可用时),接下来的 4 个作业将排队并等待轮到运行,一次一个。
有什么办法可以实现这一点吗?或者我需要向 GitHub 请求此功能吗?
我习惯使用 virtualenvs。但是由于某种原因,我无法在 github 操作作业中激活环境。
为了调试我添加了这一步:
- name: Activate virtualenv
run: |
echo $PATH
. .venv/bin/activate
ls /home/runner/work/<APP>/<APP>/.venv/bin
echo $PATH
Run Code Online (Sandbox Code Playgroud)
在操作日志上我可以看到
/opt/hostedtoolcache/Python/3.9.13/x64/bin:/opt/hostedtoolcache/Python/3.9.13/x64:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
[...] # Cut here because a lot of lines are displayed. My executables are present including the one I'm trying to execute : pre-commit.
/home/runner/work/<APP>/<APP>/.venv/bin:/opt/hostedtoolcache/Python/3.9.13/x64/bin:/opt/hostedtoolcache/Python/3.9.13/x64:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Run Code Online (Sandbox Code Playgroud)
所以它应该有效...
但接下来的步骤是
- name: Linters
run: pre-commit
Run Code Online (Sandbox Code Playgroud)
生成这些错误日志
Run pre-commit
pre-commit
shell: /usr/bin/bash -e {0}
env:
[...] # private
/home/runner/work/_temp/8e893c8d-5032-4dbb-8a15-59be68cb0f5d.sh: line 1: pre-commit: command not found
Error: Process completed with exit code 127.
Run Code Online (Sandbox Code Playgroud)
如果我这样转换上面的步骤,我没有问题: …
语境
公共存储库中的可重用工作流程可以通过附加引用来调用,该引用可以是 SHA、发布标签或分支名称,例如:
{owner}/{repo}/.github/workflows/{filename}@{ref}
Github文档指出:
当调用者工作流触发可重用工作流时,github 上下文始终与调用者工作流关联。
问题
由于 github 上下文始终与调用者工作流关联,因此可重用工作流无法访问引用,例如 tag v1.0.0。但是,当可重用工作流需要签出存储库以便使用复合操作时,了解引用非常重要。
例子
假设调用者工作流正在分支内执行,并调用可重用工作流的main引用:v1.0.0.
name: Caller workflow
on:
workflow_dispatch:
jobs:
caller:
uses: owner/public-repo/.github/workflows/reusable-workflow.yml@v1.0.0
Run Code Online (Sandbox Code Playgroud)
以下是使用复合操作的可重用工作流程:
name: reusable workflows
on:
workflow_call:
jobs:
first-job:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.1.0
with:
repository: owner/public-repo
ref: ${{ github.ref_name }}
- name: composite action
uses: ./actions/my-composite-action
Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中,${{ github.ref_name }}是main而不是v1.0.0因为 github 上下文始终与调用者工作流程相关联。因此,复合动作代码是基于main而不是基于v1.0.0. 然而,打电话的人想要v1.0.0。因此我的问题是:可重用工作流程如何能够访问调用者给出的引用?
我有一个工作流程,可以test在给定情况下自动运行作业,也可以手动运行它:
name: Test
on:
workflow_dispatch:
inputs:
used-branch:
description: Branch the test shall be run on
default: master
required: true
push:
branches: ['main', 'master']
tags: ['!**']
pull_request:
types: [opened, reopened, ready_for_review]
jobs:
test:
steps:
- name: Checkout selected branch
uses: actions/checkout@v3
if: inputs.used-branch != ''
with:
ref: ${{ github.event.inputs.used-branch }}
- name: Checkout current branch
uses: actions/checkout@v3
with:
ref: ${{github.ref}}
if: inputs.used-branch == ''
- name: Run test
...
Run Code Online (Sandbox Code Playgroud)
我希望在合并之前需要进行测试。Require status check to pass before merging因此,我检查并在存储库的分支设置中Require …
github-actions ×10
amazon-ecr ×1
bash ×1
concurrency ×1
docker ×1
flutter ×1
github ×1
github-actions-reusable-workflows ×1
github-api ×1
javascript ×1
lint ×1
next.js ×1
node.js ×1
pull-request ×1
queue ×1
terraform ×1
virtualenv ×1
workflow ×1
yarn-v2 ×1