我正在尝试设置一个 github 操作机器人,该机器人在操作运行时使用合成来构建。值得注意的是,这不是必需的,而且我知道 ncc 也会实现同样的目标,但我很好奇是否有可能以可持续的方式实现这项工作。
对于某些上下文,我正在尝试使用 yaml 脚本运行我的alita-moore/EIP-Bot私人操作...
name: "Auto Merge EIP"
description: "A bot that lints EIP edits, finds common errors, and can auto-merge"
inputs:
GITHUB-TOKEN:
description: |-
The Github token to be used by this bot when merging, posting comments, or requesting reviewers
required: true
VERSION:
description: version of the action; this is required because of how actions work
required: true
runs:
using: "composite"
steps:
- run: cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
Run Code Online (Sandbox Code Playgroud)
目前,这与给定存储库的工作流程 yaml 一起运行
on: [pull_request]
jobs:
auto_merge_bot:
runs-on: ubuntu-latest
name: EIP Auto-Merge Bot
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Node.js Enviornment
uses: actions/setup-node@v2
with:
node-version: '14'
- name: auto-merge-bot
uses: alita-moore/EIP-Bot@1.0.8
id: auto-merge-bot
with:
GITHUB-TOKEN: ${{ secrets.TOKEN }}
VERSION: 1.0.8
Run Code Online (Sandbox Code Playgroud)
你可能已经注意到,在npm ci && npm run build我首先必须cd /home/runner/work/_actions/alita-moore/EIP-Bot/${{ inputs.VERSION }}
如果你不这样做,它会抛出以下错误
Run alita-moore/EIP-Bot@1.0.1
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/runner/work/EIPs/EIPs/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/runner/work/EIPs/EIPs/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2021-03-14T09_02_26_002Z-debug.log
Error: Process completed with exit code 254.
Run Code Online (Sandbox Code Playgroud)
有一个更好的方法吗?
您可以使用${{github.action_path}}包含操作定义文件的目录路径action.yaml:
[...]
runs:
using: "composite"
steps:
- run: cd ${{github.action_path}} && npm ci && npm run build && GITHUB_TOKEN=${{ inputs.GITHUB-TOKEN }} node build/index.js
shell: bash
Run Code Online (Sandbox Code Playgroud)
github.action_path|string| 您的操作所在的路径。您可以使用此路径轻松访问与您的操作位于同一存储库中的文件。此属性仅在复合运行步骤操作中受支持。
| 归档时间: |
|
| 查看次数: |
5806 次 |
| 最近记录: |