有没有办法使用注册表中的私有映像以及自定义 GitHub Docker 容器操作的身份验证?想要将 running.image 指向私有 docker 映像。理想情况下,上传到 GitHub Packages 注册表的一个。
# action.yml
name: 'Hello World'
description: 'Greet someone'
inputs:
who_to_greet: # id of input
description: 'Who to greet'
required: true
default: 'World'
outputs:
time: # id of output
description: 'The time we greeted you'
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.who_to_greet }}
Run Code Online (Sandbox Code Playgroud)
https://docs.github.com/en/actions/creating-actions/creating-a-docker-container-action
我想当我将代码推送到github时,通过github操作自动部署github项目。我的 yaml 文件如下所示:
name: push-and-deploy-to-server
on:
push:
branches: [ main ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: appleboy/scp-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: 22
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "."
target: "."
- uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSH_HOST }}
port: 22
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
npm install
pm2 restart index.js
Run Code Online (Sandbox Code Playgroud)
我有一台带有 SSH 密钥对的服务器。公钥已添加到服务器的authorized_keys中,我可以通过终端通过SSH连接到服务器。
当我将代码推送到 github 存储库时,该操作就会运行。我收到以下错误:
Drone-scp 错误:ssh:握手失败:ssh:无法进行身份验证,已尝试方法 [无公钥],没有保留支持的方法
奇怪的是:发生此错误后,我无法再通过 SSH 连接到我的服务器,即使通过我的控制台我也收到“权限被拒绝(公钥)”的消息。所以在运行 github 操作之前,一切正常,之后就失败了。 …
这将是一本不错的读物,所以我非常感谢您的帮助:bow:
我正在尝试编写一个 github 操作配置来执行以下两个任务:
autodeploy.xar在构建文件夹中创建一个文件构建过程找不到上一步创建的文件夹/文件。所以我尝试了三件事:
尝试使用上一步中创建的文件(在 github actions 中的同一作业中),但无法运行它。
Error: buildx failed with: error: failed to solve: lstat /var/lib/docker/tmp/buildkit-mount3658977881/build/autodeploy.xar: no such file or directory尝试构建两个作业,一个用于启动文件,另一个用于needs第一个构建 docker。但是,这会产生与步骤 1 相同的错误。
尝试从任务 1 构建 docker 镜像
docker build .,但 github 操作抱怨 "docker build" requires exactly 1 argument.docker build . --file Dockerfile --tag ***/***:latest --build-arg ADMIN_PASSWORD=***这一定是非常微不足道的事情,但我不知道出了什么问题。我认为其中任何一种方法的解决方案都应该有效。
再次感谢您经历这一切。请在下面找到 GH 操作、workflow.sh 和 docker 文件:
GitHub …
我有这个 GitHub 工作流程,我需要参数化运行的运行程序。所以在 YAML 文件中我尝试了:
# ...
jobs:
process:
name: Process
runs-on: ${{ secrets.GH_RUNNER_TAG }}
# ...
Run Code Online (Sandbox Code Playgroud)
但是,我收到此错误:
The workflow is not valid. .github/workflows/action.yml (Line: 12, Col: 14): Unrecognized named-value: 'secrets'. Located at position 1 within expression: secrets.GH_RUNNER_TAG
秘密注入不适用于该元素吗?还有其他选择吗?该值不需要是秘密,但我需要将它放在一个地方,而不是每次运行者标签发生变化时都编辑数百个 YAML 文件......
EDIT1:
我已经尝试按照GuiFalourd建议在工作流程级别创建一个环境变量来保存秘密:
env:
RUNNER_LABEL: ${{ secrets.GH_RUNNER_TAG }}
jobs:
analyze:
name: Analyze
runs-on: $RUNNER_LABEL
Run Code Online (Sandbox Code Playgroud)
但这不起作用。动作卡住了。我尝试使用:
$RUNNER_LABEL -> 被卡住“$RUNNER_LABEL” -> 也被卡住 ${{ env.RUNNER_LABEL }} -> 操作无法启动,输出错误:
The workflow is not valid. .github/workflows/action.yml (Line: 14, Col: 14): Unrecognized named-value: 'env'. …
我有一个 GiHub 存储库,其中包含基于 GitHub 操作的工作流程 ( /.github/workflows/build.yml) 来进行 CI 构建。
我来自 DevOps 团队,我的情况是,开发团队的人员不允许更改 CI 管道,他们可以在功能分支上更改任何他们想要的内容,除了/.github/workflows/build.yml.
如何防止开发人员更改 GitHub 工作流程以查看其应用程序更改通过不同类型的集成构建质量检查?
除了下面提到的选项之外,还有其他更好的方法来实现这一目标吗?
1] Through PR reviews
2] Script/automation to validate PR to see if dev did any changes to (/.github/workflows/build.yml)
Run Code Online (Sandbox Code Playgroud) 由于我需要使用自托管运行器,因此使用现有市场 SSH Actions 的选项是不可行的,因为它们倾向于在 GitHub Actions 上构建镜像,但由于未知用户缺乏权限而失败。由于我对 Docker 的依赖,现有的 GitHub SSH 操作(例如 appleboy)失败了。
请注意:Appleboy 和其他类似的操作在使用 GitHub Actions Runners 时效果很好。
如果我们要使用最少的资源,执行这些步骤将类似于:
setup --- 签出,通过缓存安装固定版本
然后并行触发1个命令运行:
全部并行。
不幸的是,根据我发现的当前选项,我能找到的最佳方案是为 lint、测试、e2e 提供一个单独的工作流程文件,由主工作流程调用,并在成功构建工件后。
这个问题是。
这可以通过缓存来缓解,但是每个作业的这些步骤仍然需要 10-15 秒的额外时间。
有没有办法优化它并仍然保留可重用的步骤?
即使我将所有内容保留在 1 个巨大文件中,我仍然会将 lint、测试、e2e 步骤定义为单独的作业,而不是作业的 1 个单步部分。
我们可以调用“工作流程”并以某种方式在同一环境中运行它吗?
我正在开发一个项目,当拉取请求被批准时,GitHub 操作将被触发,如此处所述。但就我而言,至少需要 2 个批准才能批准拉取请求,因此每次批准时,操作都会开始运行。有没有办法只在一次批准后运行 GitHub 操作并忽略其他操作?
on:
pull_request_review:
types: [submitted]
jobs:
approved:
if: github.event.review.state == 'approved'
runs-on: ubuntu-latest
steps:
- run: echo "This PR was approved"
Run Code Online (Sandbox Code Playgroud) 在 GitHub Actions 中,我正在测试该actions-ecosystem/action-create-issue操作。
此操作会创建一个自动 github 问题。
但操作崩溃了,我不断收到此错误:
触发此错误(并可用于重现该错误)的工作流程 yaml 文件是以下代码:
name: Deploy to foo
on:
push:
branches: [develop]
jobs:
deploy-to-staging:
name: Deploy to Staging
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- name: Create deploy issue
uses: actions-ecosystem/action-create-issue@v1
with:
github_token: ${{ secrets.github_token }}
title: Hello World
body: |
## Deployed to Staging Server
- [ ] Task-1
- [ ] Task-2
labels: |
deploy
staging
Run Code Online (Sandbox Code Playgroud) 我无法使这个工作流程正常工作,我总是收到此错误every step must define a "uses" or "run" key,但是查看我的脚本,我没有看到任何问题,有人可以帮我解决这个问题吗?这看起来不像-平常那样是一个问题。
# This is a basic workflow to help you get started with Actions
name: Build Digital Ocean Image
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the "master" branch
push:
branches:
- '*'
- '*/*'
- '**'
- '!master'
pull_request:
branches: [ "master" ]
# Allows you to run this workflow manually from the …Run Code Online (Sandbox Code Playgroud)