我只想打印github.eventGitHub Actions 步骤中的上下文,因此我正在执行以下操作
- name: check context
shell: bash
run: echo ${{ toJSON(github.event) }}
Run Code Online (Sandbox Code Playgroud)
但是,这会失败,如下所示:
/home/runner/work/_temp/hd73999-5309-44cf-9218-9e2e3805d525.sh: line 2: after:: command not found
Error: Process completed with exit code 127.
Run Code Online (Sandbox Code Playgroud)
(尽管github.event 确实在错误发生之前打印了。
这是为什么?
我正在使用该toJSON函数,因为如果我不这样做,所有打印的内容都是:
Run echo Object
Object
Run Code Online (Sandbox Code Playgroud) 随着 Github 私人页面的出现。我实际上可以将在私人存储库中运行的 github 操作放在其中。但是,私有页面无法呈现应有权访问此私有存储库的徽章。
但是,如果我单击图像,就会看到徽章。这是因为我在 Github 中进行了身份验证,并且可以看到有关存储库的所有内容。我想知道为什么行动徽章没有显示。
我有一个包含数百个测试的存储库,到目前为止已经足够快了,但是随着我们继续扩大代码库,我担心它会变得如此缓慢,以至于我的团队将陷入等待 CI 运行完成的困境。
我可以做些什么来加快速度并使我的测试在短期和长期内都更快?
我需要考虑:
python performance continuous-integration pytest github-actions
我有以下结构:
\n.github\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 main.yml\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 send_alerts.yml\nRun Code Online (Sandbox Code Playgroud)\n现在主要是,我正在使用
\njobs:\n main:\n steps:\n - name: Git Checkout\n uses: actions/checkout@v3\n - name: some job\n run: |\n ......\n send_alerts:\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v3\n - uses: ./.github/workflows/send_alerts.yml@feature/workflow1\n with:\n provision_status: "Success"\n \nRun Code Online (Sandbox Code Playgroud)\n在我的send_alerts.yml
name: Creating and Sending Alerts/Status\non:\n workflow_call:\n \n provision_status:\n required: true\n type: string\n\njobs:\n create_send_alerts:\n runs-on: ubuntu-latest\n steps:\n - name: Git Checkout\n uses: actions/checkout@v3\n - name: Some other jobs\n run: |\n .....\nRun Code Online (Sandbox Code Playgroud)\n所以这让我犯了错误:
\nCan't find …Run Code Online (Sandbox Code Playgroud) 我想在 Windows 自托管运行器上访问之前作业的步骤结果。为了做到这一点,我使用如下输出变量,效果很好(在最后一步中打印“成功”)。
name: Debug workflow
on: workflow_dispatch
jobs:
job1:
runs-on: tester-1
outputs:
output1: ${{ steps.step1.outputs.MY_OUTPUT }}
steps:
- name: Checkout with submodules
id: checkout_step
uses: actions/checkout@v3
- name: Write variable to output
id: step1
run: echo '::set-output name=MY_OUTPUT::${{ steps.checkout_step.outcome }}'
job2:
runs-on: tester-1
needs: job1
env:
OUTPUT1: '${{needs.job1.outputs.output1}}'
steps:
- name: Print outputs from previous
run: echo ${{ env.OUTPUT1 }}
Run Code Online (Sandbox Code Playgroud)
然而::set-output 已被弃用,所以我想转换为正确的方法。根据另一个问题,我已经尝试将我的替换echo '::set-output name=MY_OUTPUT::${{ steps.checkout_step.outcome }}'为
echo "MY_OUTPUT=${{ steps.checkout_step.outcome }}" >> $env:GITHUB_ENVecho …我创建了一个工作流程文件,但该工作流程未显示在 GitHub 操作选项卡中
name: AZ Deploy Workflow
on:
workflow_dispatch:
inputs:
deploy-environment:
description: 'Environment to deploy to'
required: true
default: 'dev'
image-tag:
description: 'Docker tag to deploy'
required: true
default: 'latest'Run Code Online (Sandbox Code Playgroud)
任何想法有什么问题。
早些时候,我已将其他工作流程添加到 .github 目录中,即使放置一个空文件,它也会在操作中显示,但不会出现问题
我有两个 github 存储库(称为 A 和 B),它们都有一个.github/workflows/build_and_test.yml看起来几乎与此相同的文件:
name: Build and test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build-with-docker:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: docker/setup-buildx-action@v2
- uses: docker/build-push-action@v3
with:
tags: my_tag:latest
load: true
context: .
cache-from: type=gha
cache-to: type=gha,mode=max
- run: docker run my_tag pytest
Run Code Online (Sandbox Code Playgroud)
在回购协议A中
Dockerfile是r-base:4.2.1,大约 782MBdocker run my_tag pytest运行,一切都很好)在仓库 B 中
Dockerfile是pytorch/pytorch,大约 5.82GBIf I want to let a user override the default values in the matrix, how do I do that?
Consider the following simplified example:
name: CICD
on:
push:
branches:
- main
workflow_dispatch:
inputs:
py_version:
description: "Python version"
default: "3.11"
jobs:
test:
runs-on: ubuntu-22.04
strategy:
matrix:
py_version: [3.7, 3.10]
steps:
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
Run Code Online (Sandbox Code Playgroud)
I want to let a user override the py_version matrix list with the list provided in the workflow_dispatch input. Is there a way? …
最近,我换了一台新计算机,并在main使用简单的保护规则推送到我自己的分支时遇到了此“警告消息”。
保护规则为:
我面临以下警告消息:
remote: Bypassed rule violations for refs/heads/main:
remote:
remote: - At least 1 approving review is required by reviewers with write access.
Run Code Online (Sandbox Code Playgroud)
当推送到我的main分支时。我想知道这是否值得关注?由于我是所有者,我认为该消息不会出现。
我有两个 GitHub Actions,两者都是相同的,只是一个是手动触发的,另一个是在主分支上完成拉取请求时触发的。手动部署工作流程工作得很好,但是部署工作流程失败,并显示“错误:未授权执行 sts:AssumeRoleWithWebIdentity”。我缺少什么?我的猜测是两个事件之间的子项一定是不同的?我该如何检查?
这有效
name: manual-deploy
on:
workflow_dispatch:
env:
REACT_APP_VERSION: 0.1.0
jobs:
build-and-deploy:
runs-on: ubuntu-latest
permissions:
id-token: write
contents: read
steps:
- name: checkout code
uses: actions/checkout@v3
- name: install node
uses: actions/setup-node@v3
# using later versions of node breaks due to react-scripts v5.0.1 incompatible with typescript v5;
# this specific node version works though
with:
node-version: "16.14.2"
- name: install dependencies
run: npm install
- name: run tests
run: npm run test
- name: get current date
id: …Run Code Online (Sandbox Code Playgroud) github-actions ×10
github ×5
amazon-iam ×1
cicd ×1
diskspace ×1
docker ×1
git ×1
github-pages ×1
performance ×1
powershell ×1
pytest ×1
python ×1
workflow ×1