我有一个如下所示的 github 存储库
约翰多/你好世界
我正在尝试在 github 操作中设置以下环境变量
env:
DOCKER_HUB_USERID: ${{ github.actor }}
REPOSITORY_NAME: ${GITHUB_REPOSITORY#*\/}
IMAGE_NAME_CLIENT: "$REPOSITORY_NAME-client"
IMAGE_NAME_SERVER: "$REPOSITORY_NAME-server"
Run Code Online (Sandbox Code Playgroud)
我对这些变量的预期结果是:
johndoe
hello-world
hello-world-client
hello-world-server
Run Code Online (Sandbox Code Playgroud)
但我得到
johndoe
${REPOSITORY_NAME#*\/}
$REPOSITORY_NAME-client
$REPOSITORY_NAME-server
Run Code Online (Sandbox Code Playgroud)
看起来在声明envvars 时没有评估表达式。
我怎样才能达到预期的行为?
pipeline github environment-variables github-actions building-github-actions
我正在创建我的第一个 GitHub 操作,但我不明白为什么输出为空。
动作.yml
name: "Run Endtest functional tests"
description: "Register a deployment event with Endtest and run the functional tests"
branding:
icon: play-circle
color: white
inputs:
app_id:
description: 'The Endtest App ID for your account. You can get it from the https://endtest.io/settings page.'
required: true
app_code:
description: 'The Endtest App Code for your account. You can get it from the https://endtest.io/settings page.'
required: true
api_request:
description: 'The Endtest API request for starting the test execution.'
required: true
number_of_loops:
description: …Run Code Online (Sandbox Code Playgroud) 从我的 docker-compose 文件中我必须读取一个环境变量。在本地,我可以像这样读取该变量:ENV_FILE=.env docker-compose -f docker-compose.dev.prisma.yml up --build
但由于 .env 文件位于 .gitignore 中,GitHub 操作无法获取该文件。我怎样才能阅读它们?
我的 package.json 文件中几乎有同样的问题。我需要从 npm 脚本中读取一些环境变量:
"start:backend": "wait-port $API_HOST:API_PORT && yarn start"
Run Code Online (Sandbox Code Playgroud)
我尝试过将这些变量添加到github的秘密中,但它没有得到这些变量。尽管期望这两个文件,但 envs 可以从 github 操作中完美读取。
github environment-variables docker-compose github-actions building-github-actions
我需要帮助解决一些问题,我正在尝试根据 2 个不同的发布标签触发 2 个不同的工作流程。我希望 prod-* 触发生产工作流程,而 dev-* 触发开发工作流程。
问题是两个标签都会触发两个工作流程,我不知道如何解决这个问题
我正在尝试开发一个 Github Action,以在上传到 FTP 服务器之前更新我的(大部分)php 文件中的版本号和数据库凭据。
在我的主分支内,我有一个名为VERSION.mdcontent 的文本文件2.0.1。
该操作应该在每次推送提交时运行。
在部署到 FTP 服务器之前,需要进行这些替换(当然,不应更改真正的存储库文件,只更改上传到服务器的文件)。
__VERSION__应替换为我的文件的内容VERSION.md。db_connection.php,应将字符串__DB-PASSWORD__替换为相应的密钥DB_PASSWORD。这是我当前的工作流程:
on: push
name: FTP Deploy
jobs:
web-deploy:
name: Ubuntu VM
runs-on: ubuntu-latest
steps:
- name: Getting latest Code
uses: actions/checkout@v2.3.2
# at this position I tried the string replacing
- name: Sync Files
uses: SamKirkland/FTP-Deploy-Action@4.0.0
with:
server: ${{ secrets.ftp_server }}
username: ${{ secrets.ftp_username }}
password: ${{ secrets.ftp_password }}
server-dir: "public_html/" …Run Code Online (Sandbox Code Playgroud) 我正在尝试让私有 GitHub 操作在我的私有 GitHub 组织中工作。包含这些工作流程“模板”的私人存储库具有这个简单的文件结构,因为我只是试图让最低限度的工作:
\n.\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 .git\n\xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 test\n\xe2\x94\x82 \xe2\x94\x9c\xe2\x94\x80\xe2\x94\x80 action.yml\nRun Code Online (Sandbox Code Playgroud)\n文件action.yml内容是:
name: Test\n\non: push\n\njobs:\n test:\n name: Test\n runs-on: ubuntu-latest\n steps:\n\n - name: Echo\n run: |\n echo Heyyyyy\nRun Code Online (Sandbox Code Playgroud)\n我正在尝试在另一个私有存储库中使用此操作,并使用包含以下内容的工作流程文件:
\nname: Test\n\non:\n push:\n branches:\n - master\n\njobs:\n test:\n name: Test\n runs-on: ubuntu-latest\n steps:\n - uses: actions/checkout@v2\n with:\n repository: <private-actions-repo>\n token: ${{ secrets.REPO_TOKEN }}\n path: github-actions\n - name: Test private action\n uses: ./github-actions/test\nRun Code Online (Sandbox Code Playgroud)\n当此操作运行时,我收到以下错误:\n##[error]Top level 'runs:' section is required for /home/runner/work/<private-repo>/./github-actions/test/action.yaml
为了对此进行调试,我将使用模板的工作流程更新为该cat文件的文件内容: …
我正在编写一个 GitHub 操作,它接收一个名为fileusing @actions/corelibrary的必填输入字段。
const core = require("@actions/core");
async function run() {
try {
let file = core.getInput('file', {required: true});
// rest of my action ...
Run Code Online (Sandbox Code Playgroud)
我能够在本地运行它,但它按原样失败(未提供输入)。 是否有提供输入的内置方法(类似于 env-vars),以便我可以在本地运行和测试它?
Error: Input required and not supplied: file
at Object.getInput (.../node_modules/@actions/core/lib/core.js:78:15)
at run (.../src/main.js:6:25)
at Object.<anonymous> (.../src/main.js:40:5)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
at internal/main/run_main_module.js:17:47
::error::Input required and not supplied: file
Run Code Online (Sandbox Code Playgroud)