我想创建一个自定义Docker容器Github操作,并从这个操作开始.yml文件
name: my-action
description: For testing purposes
branding:
icon: shield
color: green
inputs:
my-input:
description: demo
required: true
runs:
using: docker
image: Dockerfile
接下来,我在根目录中的一个app.js文件中添加了一些代码
const core = require('@actions/core');
try {
const myInput = core.getInput('my-input', { required: true });
core.notice(`Input is: ${myInput}`);
} catch (error) {
core.setFailed(error.message);
}
Dockerfile
FROM node:16.13.0-alpine
USER node
WORKDIR /home/node
ADD --chown=node:node . /home/node
RUN npm install
CMD [ "node", "app.js" ]
为了测试我的操作,我发布了我的操作并创建了一个新的工作流
name: Run the action
on: workflow_dispatch
jobs:
run-the-action:
runs-on: ubuntu-latest
steps:
- name: Run the action
uses: me/my-action@v1.0.0
with:
my-input: hello
不幸的是,该操作因错误消息而崩溃
错误:找不到模块"/github/workspace/app".js'
也许我错过了从/home/node
到/github/workspace
的映射?有人知道哪里出了问题,或者如何解决吗?
如果你需要更多信息,请告诉我!