Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace misleading documentation about action inputs and outputs #33916

Merged
merged 9 commits into from
Oct 14, 2024

Conversation

piotrekkr
Copy link
Contributor

@piotrekkr piotrekkr commented Jul 10, 2024

Why:

Current docs for inputs and outputs in GitHub action metadata syntax contains some misleading statements

inputs

Optional Input parameters allow you to specify data that the action expects to use during runtime. {% data variables.product.prodname_dotcom %} stores input parameters as environment variables. Input ids with uppercase letters are converted to lowercase during runtime. We recommend using lowercase input ids.

I've tested this Input ids with uppercase letters are converted to lowercase during runtime. using

name: Demo Composite Action
description: Demo Composite Action

inputs:
  first-input ID:
    description: First input
    required: true
  second-INPUT_id:
    description: Second input
    required: false
    default: 1
  third_input_id:
    description: Third input
    required: false
runs:
  using: composite
  steps:
    - shell: bash
      run: env | grep ^INPUT_ || true
    - shell: bash
      run: echo '${{ toJSON(inputs) }}'

and nothing is converted to lowercase

image

Note: Workflows using required: true will not automatically return an error if the input is not specified for events that automatically trigger workflow runs. If you set required: true in your workflow file and are using workflow_dispatch to manually run the workflow, you will be required to specify inputs on GitHub. For more information, see "Events that trigger workflows."

Workflow files that use this action can use the with keyword to set an input value for octocat-eye-color. For more information about the with syntax, see "Workflow syntax for GitHub Actions."

This is misleading because documentation is about action metadata syntax and note is describing inputs in workflow metadata syntax. This has nothing to do with action inputs, I think.

When you specify an input in a workflow file or use a default input value, {% data variables.product.prodname_dotcom %} creates an environment variable for the input with the name INPUT_<VARIABLE_NAME>. The environment variable created converts input names to uppercase letters and replaces spaces with _ characters.

Again, this paragraph seems to be mixing workflow inputs with action inputs.

If the action is written using a composite, then it will not automatically get INPUT_<VARIABLE_NAME>. If the conversion doesn't occur, you can change these inputs manually.

Last sentence does not make much sense and I tested it. There is no INPUT_* variables present at all with composite actions. I don't even know what you can change these inputs manually part actually means. Inputs are read-only afaik, right?

inputs.<input_id>

Required A string identifier to associate with the input. The value of <input_id> is a map of the input's metadata. The <input_id> must be a unique identifier within the inputs object. The <input_id> must start with a letter or _ and contain only alphanumeric characters, -, or _.

As far as my tests got me, space characters are also valid to use in input ids.

inputs.<input_id>.description

Required A string description of the input parameter.

I tested this with composite and docker action:

name: Demo Docker Action
description: Demo Docker Action

inputs:
  first-input ID:
    required: true
  second-INPUT_id:
    required: false
    default: 1
  third_input_id:
    required: false

runs:
  using: 'docker'
  image: 'Dockerfile'
  args:
    - ${{ inputs['first-input ID'] }}
    - ${{ inputs.second-INPUT_id }}
    - ${{ inputs.third_input_id }}

and

name: Demo Composite Action
description: Demo Composite Action

inputs:
  first-input ID:
    required: true
  second-INPUT_id:
    required: false
    default: 1
  third_input_id:
    required: false
runs:
  using: composite
  steps:
    - shell: bash
      run: echo '${{ toJSON(inputs) }}'

And inputs in those action did not require any description and actions were run without problem

jobs:
  actions-examples:
    name: Actions Reuse
    runs-on: ubuntu-latest
    steps:
      - name: Use organization composite action
        uses: pkroczynski/action-demo-composite@inputs
        with:
          first-input ID: hello
      - name: Use organization docker action
        uses: pkroczynski/action-demo-docker@main
        with:
          first-input ID: hello

image

outputs.<output_id>

Required A string identifier to associate with the output. The value of <output_id> is a map of the output's metadata. The <output_id> must be a unique identifier within the outputs object. The <output_id> must start with a letter or _ and contain only alphanumeric characters, -, or _.

There seems to be also space allowed in output id. Tested with js action using core.setOutput('output 1', "test") and it was returned as action output.

outputs.<output_id>.description

Required A string description of the output parameter.

Tried and description can be omitted like below without any problems so it seems that it is optional.

outputs:
  output 1: {}

What's being changed (if available, include any code snippets, screenshots, or gifs):

Updated docs a bit to reflect what is actually happening with inputs and outputs in actions.

Check off the following:

  • I have reviewed my changes in staging, available via the View deployment link in this PR's timeline (this link will be available after opening the PR).

    • For content changes, you will also see an automatically generated comment with links directly to pages you've modified. The comment won't appear if your PR only edits files in the data directory.
  • For content changes, I have completed the self-review checklist.

@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Jul 10, 2024
Copy link
Contributor

github-actions bot commented Jul 10, 2024

Automatically generated comment ℹ️

This comment is automatically generated and will be overwritten every time changes are committed to this branch.

The table contains an overview of files in the content directory that have been changed in this pull request. It's provided to make it easy to review your changes on the staging site. Please note that changes to the data directory will not show up in this table.


Content directory changes

You may find it useful to copy this table into the pull request summary. There you can edit it to share links to important articles or changes and to give a high-level overview of how the changes in your pull request support the overall goals of the pull request.

Source Preview Production What Changed
actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions.md fpt
ghec
ghes@ 3.14 3.13 3.12 3.11 3.10
fpt
ghec
ghes@ 3.14 3.13 3.12 3.11 3.10

fpt: Free, Pro, Team
ghec: GitHub Enterprise Cloud
ghes: GitHub Enterprise Server

@Lordthevopz

This comment was marked as spam.

@nguyenalex836 nguyenalex836 added content This issue or pull request belongs to the Docs Content team actions This issue or pull request should be reviewed by the docs actions team waiting for review Issue/PR is waiting for a writer's review and removed triage Do not begin working on this issue until triaged by the team labels Jul 10, 2024
@nguyenalex836
Copy link
Contributor

@piotrekkr Thanks so much for opening a PR! I'll get this triaged for review ✨

@piotrekkr piotrekkr changed the title Replace misleading note about action inputs Replace misleading documentation about action inputs Jul 11, 2024
@piotrekkr piotrekkr changed the title Replace misleading documentation about action inputs Replace misleading documentation about action inputs and outputs Jul 14, 2024
@jc-clark jc-clark added the needs SME This proposal needs review from a subject matter expert label Jul 25, 2024
Copy link
Contributor

Thanks for opening a pull request! We've triaged this issue for technical review by a subject matter expert 👀

Copy link
Contributor

This is a gentle bump for the docs team that this PR is waiting for technical review.

@github-actions github-actions bot added the SME stale The request for an SME has staled label Aug 23, 2024
@nguyenalex836 nguyenalex836 removed the SME stale The request for an SME has staled label Aug 23, 2024
@nguyenalex836 nguyenalex836 removed the waiting for review Issue/PR is waiting for a writer's review label Sep 4, 2024
blacktatty-multi

This comment was marked as spam.

Copy link
Contributor

A stale label has been added to this pull request because it has been open 7 days with no activity. To keep this PR open, add a comment or push a commit within 3 days.

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Sep 16, 2024
@github-actions github-actions bot closed this Sep 16, 2024
@nguyenalex836 nguyenalex836 reopened this Sep 16, 2024
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Sep 16, 2024
@nguyenalex836 nguyenalex836 removed triage Do not begin working on this issue until triaged by the team stale There is no recent activity on this issue or pull request labels Sep 16, 2024
Copy link
Contributor

A stale label has been added to this pull request because it has been open 7 days with no activity. To keep this PR open, add a comment or push a commit within 3 days.

@github-actions github-actions bot added the stale There is no recent activity on this issue or pull request label Oct 14, 2024
@github-actions github-actions bot closed this Oct 14, 2024
@nguyenalex836 nguyenalex836 reopened this Oct 14, 2024
@nguyenalex836 nguyenalex836 removed the stale There is no recent activity on this issue or pull request label Oct 14, 2024
@github-actions github-actions bot added the triage Do not begin working on this issue until triaged by the team label Oct 14, 2024
nguyenalex836
nguyenalex836 previously approved these changes Oct 14, 2024
@nguyenalex836
Copy link
Contributor

@piotrekkr Thank you for addressing that feedback! I've approved the PR - once you are able to resolve those conflicts, we can get this merged 💛

@nguyenalex836 nguyenalex836 removed the triage Do not begin working on this issue until triaged by the team label Oct 14, 2024
@piotrekkr
Copy link
Contributor Author

@nguyenalex836 I've rebased this PR on latest code from main.

@nguyenalex836 nguyenalex836 added this pull request to the merge queue Oct 14, 2024
@nguyenalex836
Copy link
Contributor

@piotrekkr Thank you! Getting this merged now 💛

Merged via the queue into github:main with commit c9cb373 Oct 14, 2024
46 checks passed
Copy link
Contributor

Thanks very much for contributing! Your pull request has been merged 🎉 You should see your changes appear on the site in approximately 24 hours. If you're looking for your next contribution, check out our help wanted issues

@piotrekkr piotrekkr deleted the patch-2 branch October 15, 2024 07:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
actions This issue or pull request should be reviewed by the docs actions team content This issue or pull request belongs to the Docs Content team SME reviewed An SME has reviewed this issue/PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants