為了成功地將引數從 GitHub 作業流傳遞到 GitHub 自定義操作,必須在下面的代碼中更改哪些特定語法?
作業流檔案代碼位于.github/workflows/mycustomworkflow.yml并包含以下代碼:
name: send-param-into-custom-action
on:
push:
branches:
- dev
jobs:
send-the-param:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- id: SendParamIntoCustomAction
uses: ./.github/actions/my-custom-action
with:
custom_param: "Some literal string"
GitHub 操作檔案位于.github/actions/my-custom-action/action.yml并包含以下代碼:
name: 'Pass a parameter into a custom action'
description: 'Receives a parameter and prints it out.'
runs:
using: "composite"
steps:
- shell: bash
name: Print the parameter value
env:
custom_param: ${{ inputs.custom_param }}
run: |
echo 'About to echo the parameter value'
echo $custom_param
uj5u.com熱心網友回復:
您需要元資料檔案中的inputs物件:
name: Pass a parameter into a custom action
description: Receives a parameter and prints it out.
inputs:
custom_param:
description: Custom input parameter
required: true
runs:
using: composite
steps:
- shell: bash
name: Print the parameter value
env:
custom_param: ${{ inputs.custom_param }}
run: |
echo 'About to echo the parameter value'
echo "$custom_param"
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/516591.html
