您好,我正在使用 Github 操作 AWS EC2 和 IAM 策略来构建和推送 docker 映像。但是我收到以下错误:
错误:buildx 失败,原因:错误:无法解决:意外状态:403 禁止。
我使用的iam策略如下:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecr:CompleteLayerUpload",
"ecr:GetAuthorizationToken",
"ecr:UploadLayerPart",
"ecr:InitiateLayerUpload",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage"
],
"Resource": "*"
}
]
}
Run Code Online (Sandbox Code Playgroud)
不知道我应该做什么才能让它发挥作用
即使我们剪切并粘贴了之前运行的命令release not found返回的版本的精确名称,也会抛出退出代码 1 的错误。gh release list --repo $repoWithToken
GitHub 错误日志的相关部分是:
About list releases
exact_name_of_release_linux_n.1.2 _linux_n.1.2 2022-09-19T23:28:08Z
About to download release
release not found
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
完整的工作流程代码如下:
About list releases
exact_name_of_release_linux_n.1.2 _linux_n.1.2 2022-09-19T23:28:08Z
About to download release
release not found
Error: Process completed with exit code 1.
Run Code Online (Sandbox Code Playgroud)
该$repoWithToken变量已正确填充,因为gh release list --repo $repoWithToken命令运行时没有错误,如上面的日志所示。
以上使用此链接中的文档。
当我们更改命令以使用标签名称以gh release download _linux_n.1.2 --repo $repoWithToken更类似于链接中文档中给出的示例时,会引发相同的错误。
gh release download为了 …
我有一个 github 操作,它有一个输入,该输入应该具有基于 env.variable 的默认值。因为 github actions 不支持该default字段中的 env 变量,所以我想知道是否可以在我的 action.yml 文件的步骤部分中重新分配 input.variable 。
到目前为止,这是我尝试过的:
不起作用:
...
inputs:
...
mono-build-tag:
description: Release tag to download from the mono-build-repo
# Github Actions complains that env is being used here
default: "${{ env.GODOT_MONO_BUILD_TAG }}"
runs:
using: "composite"
steps:
- name: Setup default inputs
run: |
if ${{ inputs.mono-build-repo == '' }}
...
Run Code Online (Sandbox Code Playgroud)
不起作用:
...
inputs:
...
mono-build-tag:
description: Release tag to download from the mono-build-repo
default: ""
runs:
using: "composite" …Run Code Online (Sandbox Code Playgroud) 我的存储库中有 2 个 Github Actions 工作流程,其中一个步骤需要获取 PR 中已修改的所有文件(删除的文件除外)。我在第一个中使用这个:
on:
pull_request:
branches: [ main ]
jobs:
get_files:
name: run_on_pr
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Modified files
run: |
git fetch origin main:main
git diff --name-only --diff-filter=d main~ main
Run Code Online (Sandbox Code Playgroud)
这个工作正常,我可以获得所有已修改文件的列表。但是,在第二个工作流程中(应该在合并 PR 时运行),这不起作用。
on:
push:
branches: [ main ]
jobs:
get_files:
name: run_when_pr_is_merged
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@master
with:
fetch-depth: 0
- name: Modified files
run: |
git fetch origin …Run Code Online (Sandbox Code Playgroud) GitLab 有一个工具CI Lint,可用于验证和检查GitLab Pipelines的 CI/CD 语法。
GitHub 是否有GitHub Actions的等效工具?
我已经搜索过,但到目前为止找不到任何同等的东西......
在Github Actions复合操作中,必须指定复合操作所在的分支,例如:
- uses: /username/repo-name/.github/composite-actions@main
Run Code Online (Sandbox Code Playgroud)
有没有办法指定当前分支而不是硬编码@main?
我可以看到.pkl使用actions/download-artifact@v3工作目录中的操作下载的内容Dockerfile,如下所示,
当我尝试COPY在 Dockefile 中归档时,出现文件未找到错误。
在构建 docker 镜像之前,如何复制下载的 docker 镜像内的文件(通过 github actions)?
这是github 上关于 docker 支持的文档,但我没有确切地知道如何解决我的问题。任何帮助将非常感激!!
Dockerfile:
name: Docker - GitHub workflow
env:
CONTAINER_NAME: xxx-xxx
on:
workflow_dispatch:
push:
branches: ["main"]
pull_request:
branches: ["main"]
permissions:
id-token: write
contents: read
jobs:
load-artifacts:
runs-on: ubuntu-latest
environment: dev
env:
output_path: ./xxx/xxx_model.pkl
steps:
- uses: actions/checkout@v3
- name: Download PPE model file
run: |
az storage blob download --container-name ppe-container --name xxx_model.pkl -f "${{ env.output_path }}" …Run Code Online (Sandbox Code Playgroud) 我的存储库包含main.py生成 html 地图并将结果保存在 csv 中的 a。我希望该行动:
name: refresh map
on:
schedule:
- cron: "30 11 * * *" #runs at 11:30 UTC everyday
jobs:
getdataandrefreshmap:
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v3 # checkout the repository content to github runner.
- name: setup python
uses: actions/setup-python@v4
with:
python-version: 3.8 #install the python needed
- name: Install dependencies
run: |
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: execute …Run Code Online (Sandbox Code Playgroud) 我无法将使用 github 操作构建的 dist 文件夹复制到 docker 映像中...
github 操作文件:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: bahmutov/npm-install@v1
- run: yarn install
- run: yarn workspace client build
- run: bash collectclient.sh
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ctrlmaniac
password: ${{ secrets.DOCKERHUB_PASSWORD }}
- name: Build and push
uses: docker/build-push-action@v3
with:
push: true
tags: ctrlmaniac/me:latest
Run Code Online (Sandbox Code Playgroud)
该collectclient.sh文件将简单地将构建文件夹复制到项目的根目录中并将其重命名为 public。
#!/usr/bin/bash
echo "Removing old files"
rm -rf public …Run Code Online (Sandbox Code Playgroud) 在 GitHub 作业工作流程中,github 操作通常按版本引用,例如actions/checkout@v3
jobs:
build:
steps:
- name: Checkout repository
uses: actions/checkout@v3
Run Code Online (Sandbox Code Playgroud)
当我访问 Action 的发布页面时,我看到当前版本是 3.2.0。
问题:
actions/checkout@v3执行工作流时是否使用最新的次要版本。github-actions ×10
github ×5
docker ×2
python ×2
amazon-ecr ×1
amazon-iam ×1
fastapi ×1
git ×1
github-cli ×1
gitlab-ci ×1