我正在尝试编写一个自定义 github-action,它在 docker 容器中运行一些命令,但允许用户选择他们在哪个 docker 容器中运行(即,我可以在不同版本的运行时环境中运行相同的构建指令)
我的直觉是将我的.github/actions/main/action.yml文件作为
name: 'Docker container command execution'
inputs:
dockerfile:
default: Dockerfile_r_latest
runs:
using: 'docker'
image: '${{ inputs.dockerfile }}'
args:
- /scripts/commands.sh
Run Code Online (Sandbox Code Playgroud)
但是,此错误与:
##[error](Line: 7, Col: 10): Unrecognized named-value: 'inputs'. Located at position 1 within expression: inputs.dockerfile
任何帮助,将不胜感激 !
我的.github/workflow/build_and_test.yml文件是:
name: Test Package
on:
[push, pull_request]
jobs:
R_latest:
name: Test on latest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
name: Checkout project
- uses: ./.github/actions/main
name: Build and test
with:
dockerfile: Dockerfile_r_latest …Run Code Online (Sandbox Code Playgroud) 需要在 docker 镜像中增加观察者,因为它在 expo 发布时失败并出现错误
[11:39:08] Error: ENOSPC: System limit for number of file watchers reached, watch '/__w/mevris-client-app-products/mevris-client-app-products/node_modules/update-notifier/node_modules/camelcase'
[11:39:08] at FSWatcher.start (internal/fs/watchers.js:165:26)
[11:39:08] at Object.watch (fs.js:1258:11)
[11:39:08] at NodeWatcher.watchdir (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/node_watcher.js:159:22)
[11:39:08] at Walker.<anonymous> (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/metro/node_modules/sane/src/common.js:109:31)
[11:39:08] at Walker.emit (events.js:198:13)
[11:39:08] at /__w/mevris-client-app-products/mevris-client-app-products/node_modules/walker/lib/walker.js:69:16
[11:39:08] at go$readdir$cb (/__w/mevris-client-app-products/mevris-client-app-products/node_modules/@react-native-community/cli/node_modules/graceful-fs/graceful-fs.js:187:14)
[11:39:08] at FSReqWrap.args [as oncomplete] (fs.js:140:20)
Run Code Online (Sandbox Code Playgroud)
在 Dockerfile 中添加了以下几行
RUN echo "fs.inotify.max_user_instances=524288" >> /etc/sysctl.conf && sysctl -p
Run Code Online (Sandbox Code Playgroud)
构建时导致此错误
sysctl: setting key "fs.inotify.max_user_watches": Read-only file system
我需要在 Github Actions 中使用那个 docker 镜像
文件
FROM node:10
RUN …Run Code Online (Sandbox Code Playgroud) 这是为 GitHub 问题评论设置操作触发器的方式.github/workflows/main.yml:
on:
issue_comment:
types: [created, edited]
Run Code Online (Sandbox Code Playgroud)
我假设我也可以阅读里面的问题评论main.yml并将其作为输入参数传递给我的操作。
我如何实际阅读问题评论body?
我有 git 操作来运行 prettier(代码格式化程序)。下面是format.ymlgit操作的文件。
name: Format code with prettier
on:
push:
branches-ignore:
- master
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
# Install NPM dependencies, cache them correctly
- name: Run prettier
run: |
npm ci
npm run prettier-check
Run Code Online (Sandbox Code Playgroud)
下面列出了我收到的错误。
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old …Run Code Online (Sandbox Code Playgroud) 我想使用 Github Actions 进行 CI 并在合并分支之前运行测试。
我有一个存储库,其中包含我的服务器和前端(Nest 和 Angular)。
我正在使用 Cypress/Jest 进行测试。
我需要运行后端服务器才能通过前端 cypress 测试。
目前 GH Actions 不会进入下一步,因为后端进程正在运行 - 但这就是我需要发生的事情......
我应该如何设置才能将 GH Actions 用于 CI?
name: test
on: [push]
env:
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OTHER_SECRETS: ${{ secrets.otherSecrets }}
jobs:
cypress-run:
runs-on: macos-11
steps:
# start cypress w/github action: https://github.com/cypress-io/github-action
- name: Setup Node.js environment
uses: actions/setup-node@v2.5.0
with:
node-version: '16.13.0'
- name: Checkout
uses: 'actions/checkout@v2'
- name: "Start Backend"
run: |
cd server &&
npm install …Run Code Online (Sandbox Code Playgroud) 在“组织”github帐户中,我可以设置一些全局秘密,PYPI_USERNAME并使PYPI_PASSWORD它们“可用于公共存储库”,然后在我的中使用它们,ci.yml如下所示:
twine upload dist/$PROJECT_NAME-$VERSION.tar.gz -u ${{ secrets.PYPI_USERNAME }} -p ${{ secrets.PYPI_PASSWORD }} --non-interactive --skip-existing --disable-progress-bar
Run Code Online (Sandbox Code Playgroud)
但在我的“用户”github 帐户中,我找不到任何此类组织范围内的秘密,因此我发现自己必须为每个单独的存储库输入我的秘密,这是反人类罪(现在)。
通过 GitHub 操作将更改推送到我自己的公共存储库时,我收到此错误。
remote: Permission to spooky/repo.git denied to github-actions[bot].
fatal: unable to access 'https://github.com/spooky/repo/': The requested URL returned error: 403
Error: Process completed with exit code 128.
Run Code Online (Sandbox Code Playgroud)
操作中的提交代码是
- name: Commit Output files
run: |
git config remote.origin.url 'https://github_token@github.com/spooky/repo/'
git config --local user.email "spook@gmail.com"
git config --local user.name "spook"
git init
git add .
git commit -m "Updated"
git push origin main
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: github_token
Run Code Online (Sandbox Code Playgroud)
我也尝试过git config remote.origin.url 'https://username:github_token@github.com/spooky/repo/',得到同样的错误(GitHub 令牌具有所有权限)。
谁能帮我解决这个问题吗?
我一直在 GitHub Actions 中快速了解 Docker 的使用情况,并且不断运行如下代码:
docker run --rm -t \
-v "/home/runner":"/home/runner" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
-v "${{ github.workspace }}":"/github/workspace" \
...
Run Code Online (Sandbox Code Playgroud)
我很好奇安装所有这些卷的动机是什么。我得到了/github/workspace一个,可以访问 Docker 容器内的所有存储库文件,但是这些文件有什么用呢?
/home/runner/home/runner/work/_temp/_github_home/home/runner/work/_temp/_github_workflow“你说什么,你在哪里看到的?”
然而,我找不到任何有关您为什么要这样做的文档。
我正在尝试使用类似于以下的结构来组织我的工作流程工件(在自托管运行器上):
c:\github\artifacts\{org}\{repo}\{runid}
Run Code Online (Sandbox Code Playgroud)
我们企业中的不同组织可以拥有同名的存储库,因此我希望能够按组织名称进行组织。
到目前为止我有这个:
c:\github\artifacts\{org}\{${{ github.event.repository.name }}\${{ github.run_id }}\
Run Code Online (Sandbox Code Playgroud)
如何确定组织名称?
github-actions ×10
docker ×3
github ×2
cypress ×1
dockerfile ×1
file-watcher ×1
git ×1
git-push ×1
github-actions-self-hosted-runners ×1
jestjs ×1
node.js ×1
npm ×1
npm-ci ×1
postgresql ×1