From 8812fabcbc3004339449c31f1bd3d341c30f954d Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 14:13:00 +0300 Subject: [PATCH 1/8] Update action.yml --- action.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/action.yml b/action.yml index 6e6af24..6105d84 100644 --- a/action.yml +++ b/action.yml @@ -5,6 +5,10 @@ inputs: description: 'Whether to print environment variables' required: false default: 'false' + add_to_summary: + description: 'Whether to add inputs to GitHub Summary' + required: false + default: 'false' outputs: output: description: 'The output of the action' @@ -20,6 +24,7 @@ runs: shell: bash env: PRINT_ENV_VARS: ${{ inputs.print_env_vars }} + ADD_TO_SUMMARY: ${{ inputs.add_to_summary }} run: | output=$( echo "Checking for workflow_dispatch inputs:" @@ -28,6 +33,11 @@ runs: inputs=$(jq -r '.inputs // empty' "$GITHUB_EVENT_PATH") if [ -n "$inputs" ] && [ "$inputs" != "null" ]; then echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' + if [ "$ADD_TO_SUMMARY" = "true" ]; then + echo -e "\n
\nWorkflow Dispatch Inputs\n\n\`\`\`" >> $GITHUB_STEP_SUMMARY + echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' >> $GITHUB_STEP_SUMMARY + echo -e "\n\`\`\`\n
" >> $GITHUB_STEP_SUMMARY + fi else echo "No workflow_dispatch inputs found in the event payload." fi From 30c9f48ee1cf01457dcd340047fa5d5309bb743a Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 15:05:19 +0300 Subject: [PATCH 2/8] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index 6105d84..e1ae8d9 100644 --- a/action.yml +++ b/action.yml @@ -34,7 +34,7 @@ runs: if [ -n "$inputs" ] && [ "$inputs" != "null" ]; then echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' if [ "$ADD_TO_SUMMARY" = "true" ]; then - echo -e "\n
\nWorkflow Dispatch Inputs\n\n\`\`\`" >> $GITHUB_STEP_SUMMARY + echo -e "\n
\nInputs\n\n\`\`\`" >> $GITHUB_STEP_SUMMARY echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' >> $GITHUB_STEP_SUMMARY echo -e "\n\`\`\`\n
" >> $GITHUB_STEP_SUMMARY fi From dcf6df888c629acd3695c90075ebed228dcbbafd Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 15:08:08 +0300 Subject: [PATCH 3/8] Update test.yaml --- .github/workflows/test.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index effcfb6..a727e13 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -45,6 +45,8 @@ jobs: - name: Run action (inputs expected) uses: ./ id: print_inputs + with: + add_to_summary: true - name: Check output (inputs expected) run: | echo "Action output:" @@ -56,6 +58,7 @@ jobs: echo "Test failed: Inputs were not printed as expected for workflow_dispatch event" exit 1 fi + test-env-vars: runs-on: ubuntu-latest From be0b095f4d8b2101fc89b4d68d25bfe9dcb219d2 Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 15:10:27 +0300 Subject: [PATCH 4/8] Update action.yml --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index e1ae8d9..e3f2f49 100644 --- a/action.yml +++ b/action.yml @@ -36,7 +36,7 @@ runs: if [ "$ADD_TO_SUMMARY" = "true" ]; then echo -e "\n
\nInputs\n\n\`\`\`" >> $GITHUB_STEP_SUMMARY echo "$inputs" | jq -r 'to_entries[] | "\(.key): \(.value)"' >> $GITHUB_STEP_SUMMARY - echo -e "\n\`\`\`\n
" >> $GITHUB_STEP_SUMMARY + echo -e "\`\`\`\n
" >> $GITHUB_STEP_SUMMARY fi else echo "No workflow_dispatch inputs found in the event payload." From 1be4a543a4e74f1ad1fccad96e4df36a0e401d58 Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 15:47:57 +0300 Subject: [PATCH 5/8] Update README.md --- README.md | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 6649096..eff70e3 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,13 @@ # Print Workflow Dispatch Inputs and Env Vars -This GitHub Action prints all input values from a `workflow_dispatch` event to the log. Optionally, it can also print all environment variables. It's a simple and effective tool for debugging or verifying input values and environment settings in your manually triggered workflows. +This GitHub Action prints all input values from a `workflow_dispatch` event to the log. Optionally, it can also print environment variables and add inputs to the GitHub Summary in a collapsible format. ## Features - Prints all `workflow_dispatch` inputs to the log - Optionally prints all environment variables +- Optionally adds inputs to GitHub Summary in a collapsible format - Minimal configuration required -- Doesn't require a GitHub token - Lightweight and fast ## Usage @@ -34,26 +34,28 @@ jobs: runs-on: ubuntu-latest steps: - name: Print Workflow Dispatch Inputs and Env Vars - uses: shayki5/print-workflow-dispatch-inputs@v1 + uses: your-username/print-workflow-dispatch-inputs@v1 with: - print_env_vars: 'true' # Set 'true' to print environment variables as well (default: false) + print_env_vars: 'true' # Set to 'true' to print environment variables + add_to_summary: 'true' # Set to 'true' to add inputs to GitHub Summary ``` -When you manually trigger this workflow and provide values for the inputs, the action will print these input values to the log. If `print_env_vars` is set to 'true', it will also print all environment variables. - ## Inputs | Input | Description | Required | Default | |-------|-------------|----------|---------| | `print_env_vars` | Whether to print environment variables | No | 'false' | +| `add_to_summary` | Whether to add inputs to GitHub Summary | No | 'false' | -## How it Works +## Outputs -This action reads the event payload from the `GITHUB_EVENT_PATH` environment variable, which is automatically set by GitHub Actions. It then uses `jq` to extract and print the input values. If `print_env_vars` is set to 'true', it also prints all environment variables using the `env` command. +| Output | Description | +|--------|-------------| +| `output` | The full output of the action | -## Requirements +## GitHub Summary -This action is designed to work with `workflow_dispatch` events. It will not print inputs for other event types, but can still print environment variables if enabled. +When `add_to_summary` is set to 'true', the action will add the workflow dispatch inputs to the GitHub Summary in a collapsible format. This allows you to easily view the inputs without cluttering the summary. ## License @@ -61,7 +63,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file ## Contributing -Contributions, issues, and feature requests are welcome! Feel free to check [issues page](https://github.com/shayki5/print-workflow-dispatch-inputs/issues). +Contributions, issues, and feature requests are welcome! Feel free to check [issues page](https://github.com/your-username/print-workflow-dispatch-inputs/issues). ## Support From 20eb29dec867030ddf39efb0f0998de85ac88635 Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Thu, 25 Jul 2024 15:49:28 +0300 Subject: [PATCH 6/8] Update README.md --- README.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index eff70e3..02e3438 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Print Workflow Dispatch Inputs and Env Vars - uses: your-username/print-workflow-dispatch-inputs@v1 + uses: shayki5/print-workflow-dispatch-inputs@v1 with: print_env_vars: 'true' # Set to 'true' to print environment variables add_to_summary: 'true' # Set to 'true' to add inputs to GitHub Summary @@ -47,11 +47,6 @@ jobs: | `print_env_vars` | Whether to print environment variables | No | 'false' | | `add_to_summary` | Whether to add inputs to GitHub Summary | No | 'false' | -## Outputs - -| Output | Description | -|--------|-------------| -| `output` | The full output of the action | ## GitHub Summary @@ -63,7 +58,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file ## Contributing -Contributions, issues, and feature requests are welcome! Feel free to check [issues page](https://github.com/your-username/print-workflow-dispatch-inputs/issues). +Contributions, issues, and feature requests are welcome! Feel free to check [issues page](https://github.com/shayki5/print-workflow-dispatch-inputs/issues). ## Support From 3b391f973d9ea4d39668ca76f6847739c89f3598 Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Sun, 28 Jul 2024 11:22:17 +0300 Subject: [PATCH 7/8] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 02e3438..8b3bc51 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Print Workflow Dispatch Inputs and Env Vars +# Print Workflow Dispatch Inputs This GitHub Action prints all input values from a `workflow_dispatch` event to the log. Optionally, it can also print environment variables and add inputs to the GitHub Summary in a collapsible format. From 5095cca0beb690df9ccdb1e046e1fec323934219 Mon Sep 17 00:00:00 2001 From: Shayki Abramczyk Date: Sun, 28 Jul 2024 11:23:32 +0300 Subject: [PATCH 8/8] Update action.yml --- action.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/action.yml b/action.yml index e3f2f49..abdd443 100644 --- a/action.yml +++ b/action.yml @@ -1,5 +1,5 @@ -name: 'Print Workflow Dispatch Inputs and Env Vars' -description: 'A GitHub Action that prints all workflow_dispatch input values and optionally environment variables to the log' +name: 'Print Workflow Dispatch Inputs' +description: 'A GitHub Action that prints all workflow_dispatch input values and optionally environment variables to the log. optionally can add inputs to the GitHub Summary in a collapsible format.' inputs: print_env_vars: description: 'Whether to print environment variables'