以下是我的 Github Actions 的 yml 文件。我想通过 docker 选项 ( ) 将 docker 用户设置为 root --user root。我如何通过 Github Actions 做到这一点?
name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: run zap
uses: docker://sshniro/zap_action
with:
args: zap-baseline.py -t https://www.example.com
Run Code Online (Sandbox Code Playgroud)
提前致谢。
我正在使用fastlane Github 操作。我需要以 root 用户身份运行它。
- name: Deploy
uses: maierj/fastlane-action@v1.4.0
with:
lane: 'alpha'
subdirectory: 'android-staging'
Run Code Online (Sandbox Code Playgroud)
我怎样才能以 sudo 方式运行它?
我创建了一个管道,我想每次推送任何分支时触发
有我的default.yml:
name: default
on:
push:
branches:
- '*'
jobs:
build:
runs-on: macOS-latest
steps:
- uses: actions/checkout@v1
- name: CocoaPod Install
run: pod install
- name: Force xcode version
run: sudo xcode-select -switch /Applications/Xcode_11.2.1.app
- name: Build
run: ./pipelines.sh build
Run Code Online (Sandbox Code Playgroud)
当我把这个推到github上时,我遇到了这个错误
没有定义事件触发器
on
我有以下回购结构。
\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .cosmos\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 .config\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .github\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 workflows\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 plan.yml\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 update.yml\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .gitignore\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 README.md\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 assets\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 1.png\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 2.png\n\xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 3.png\n\xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 us-west-2\n \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 applications\n \xe2\x94\x82\xc2\xa0\xc2\xa0 \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 test.json\n \xe2\x94\x94\xe2\x94\x80\xe2\x94\x80 cluster-config.json\nRun Code Online (Sandbox Code Playgroud)\n以及以下 GH Action yaml 文件。
\n计划.yml
\nname: Cosmos Plan\n\non:\n pull_request:\n paths:\n - "**/applications/*.json"\n - "**/cluster-config.json"\n\njobs:\n find:\n name: Find edited clusters\n runs-on: ubuntu-latest\n outputs:\n new: ${{ steps.find.outputs.new }}\n modified: ${{ steps.find.outputs.modified }}\n anyNew: ${{ steps.find.outputs.anyNew }}\n anyModified: ${{ steps.find.outputs.anyModified }}\n steps:\n - name: Checkout\n uses: actions/checkout@v2\n\n - name: …Run Code Online (Sandbox Code Playgroud) 我有一个 CI,它在创建的每个拉取请求和每次推送新提交时运行。此 CI 安装 Python 依赖项,然后运行一些测试。我使用两个单独的requirements.txt 文件,因为其中一个包含较重的包,并且它们在 Docker 中的处理方式不同。我正在尝试使用actions/cache@v2操作来缓存依赖项,但据我所知,它仅在同一分支中的运行之间进行缓存。因此,例如,当我创建新的 PR 时,不会从另一个分支检测到缓存,并且所有内容都会从头开始安装。有没有办法缓存工作流运行之间的依赖关系?那么,如果需求没有发生任何变化,CI 在一个分支中创建的缓存可以被另一个分支使用吗?
查看在两个不同分支中运行的工作流的日志,缓存键是相同的:
branchACache not found for input keys: /opt/hostedtoolcache/Python/3.8.12/x64-03a86b868f006751e123da18168c989ab4c3c2713de4f5c87cf732ffbb6fb4ae-cd1b416332d9d5b55f413e2bd74c2efce6107aef1ce3f497fa5a81b9abc83deb
Run Code Online (Sandbox Code Playgroud)
branchBCache not found for input keys: /opt/hostedtoolcache/Python/3.8.12/x64-03a86b868f006751e123da18168c989ab4c3c2713de4f5c87cf732ffbb6fb4ae-cd1b416332d9d5b55f413e2bd74c2efce6107aef1ce3f497fa5a81b9abc83deb
Run Code Online (Sandbox Code Playgroud)
Cache not found for input keys: /opt/hostedtoolcache/Python/3.8.12/x64-03a86b868f006751e123da18168c989ab4c3c2713de4f5c87cf732ffbb6fb4ae-cd1b416332d9d5b55f413e2bd74c2efce6107aef1ce3f497fa5a81b9abc83deb
Run Code Online (Sandbox Code Playgroud) Github Actions 允许使用 Docker 容器来运行作业,但它似乎不允许为此容器映像提供动态值(使用环境变量)。
这有效(不是所需的解决方案):
jobs:
pytest-test:
container:
image: ghcr.io/ashrafgt/test:latest ...
Run Code Online (Sandbox Code Playgroud)
这不起作用(所需的解决方案):
jobs:
pytest-test:
container:
# env variables defined at the start of the workflow
image: ${{ env.REGISTRY_NAME }}/test:${{ env.IMAGE_TAG }}
...
Run Code Online (Sandbox Code Playgroud)
给出这个错误:
Invalid workflow file : .github/workflows/workflow.yaml
The workflow is not valid. Unrecognized named-value: 'env'. Located at position 1 within expression: env.REGISTRY_NAME
Run Code Online (Sandbox Code Playgroud)
除了执行 a 之外,还有其他方法可以做到这一点吗run: docker run ...?
在此示例中,我尝试构建并推送 Docker 映像(用当前提交 SHA 标记),然后使用相同的映像来运行单元测试:
name: Main CI Pipeline
on: [push]
env:
REGISTRY_NAME: ghcr.io/${{ github.repository_owner }} …Run Code Online (Sandbox Code Playgroud) - name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@master
with:
role-to-assume: ${{secrets.ARN_GITHUB_ACTIONS_ROLE_UAT}}
aws-region: ${{secrets.AWS_REGION}}
Run Code Online (Sandbox Code Playgroud)
这是我收到错误的地方,并且我无权访问云路径来查看历史记录,可能有人更改了凭据或删除了角色?
xml openid amazon-web-services openid-connect github-actions
我想将我的工作流程的并发限制为一次运行:
on:
pull_request:
paths:
- 'foo/**'
push:
paths:
- 'foo/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
Run Code Online (Sandbox Code Playgroud)
但是,我发现 forpush head_ref是空的并且run_id始终是唯一的(如下所述: https: //docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using- a-后备值)
如何创建一个在事件中保持不变的并发pull_request键push?
我想创建一个带有一些条件作业的 GitHub Action。我想并行运行这些条件作业,但完成后我想继续执行另一项需要等待完成所有条件作业的作业。
这是我想要实现的工作流程:
npm run prod更改的内容这是我的deploy.yml文件:
name: Deploy
on:
push:
branches:
- deploy
jobs:
check-theme-changes:
name: Check template changes
outputs:
run_job: ${{ steps.check_files.outputs.run_job }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: check modified files
id: check_files
run: |
echo "=============== list modified files ==============="
git diff --name-only HEAD^ HEAD
echo "========== check paths of modified files =========="
git diff --name-only HEAD^ HEAD > files.txt …Run Code Online (Sandbox Code Playgroud) 标题几乎是不言自明的,ssh 连接失败。我的物理服务器就在我旁边,它位于一个 VPN 下,该 VPN 在 ssh 之前连接。
看起来服务器拒绝用户/密码对,但它在我的计算机上的终端上运行得很好。
sshd_config 文件具有 PasswordAuthentication yes ,我使用service ssh restart重新启动了 ssh 服务。
这是工作流程:
name: Deployment
on:
push:
branches: [ master ]
jobs:
deploy:
runs-on: ubuntu-20.04
steps:
- name: Set up WireGuard
uses: egor-tensin/setup-wireguard@v1
with:
endpoint: ${{ secrets.WIREGUARD_ENDPOINT }}
endpoint_public_key: ${{ secrets.WIREGUARD_ENDPOINT_PUBLIC_KEY }}
ips: ${{ secrets.SERVER_IP }}
allowed_ips: ${{ secrets.WIREGUARD_ALLOWED_IPS }}
private_key: ${{ secrets.WIREGUARD_PRIVATE_KEY }}
- name: Deploy to server
# don't run locally
if: ${{ !env.ACT }}
uses: appleboy/ssh-action@master
with:
host: ${{ …Run Code Online (Sandbox Code Playgroud)