Reusable workflows in GitHub Actions can receive input environmental variables by defining input parameters in the workflow file. These input parameters can then be referenced and passed as arguments to reusable workflows.
Here's an example of how to define input parameters in a reusable workflow:
# in reusable-workflow.yml
name: My Reusable Workflow
on: push
inputs:
my-variable:
description: 'An example environmental variable input'
required: true
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Print the input variable
run: echo "I received the input variable: ${{ inputs.my-variable }}"
In this example, the reusable workflow takes one required input variable called my-variable
. The variable is then referenced in a step that prints its value.
To use this reusable workflow with input variables, you can reference it in your main workflow file and pass the input variables like this:
# in main-workflow.yml
name: My Main Workflow
on: push
jobs:
my-job:
runs-on: ubuntu-latest
steps:
- name: Use the reusable workflow
uses: my-org/my-repo/reusable-workflow@main
with:
my-variable: 'hello world'
In this example, the main workflow file references the reusable workflow and passes the my-variable
input with the value 'hello world'
.
Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss
Asked: 2023-06-03 06:17:01 +0000
Seen: 2 times
Last updated: Jun 03 '23
How can I deal with Expression.Error related to a column in Power Query?
How can you implement pagination in Oracle for the LISTAGG() function?
What is the process for implementing a FutureBuilder on an OnTap function in Flutter?
How can we require users to be logged in before they can access the root folders in WordPress?
In SCSS, what is the method for grouping and reusing a set of classes and styles?
How can popen() be used to direct streaming data to TAR?
How does iOS retrieve information from a BLE device?
How can Django Admin accommodate a variety of formats and locales for its input fields?