Skip to content

Commit

Permalink
Print a warning if a GITHUB_* variable from this action already exists
Browse files Browse the repository at this point in the history
Related to #77

Add a warning for existing GITHUB_* variables in the preflight.sh script.

* Check for existing GITHUB_* variables using the env command.
* Print a warning if any existing GITHUB_* variables are found.
* Update action.yml to capture and print warnings from preflight.sh.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/rlespinasse/github-slug-action/issues/77?shareId=XXXX-XXXX-XXXX-XXXX).
  • Loading branch information
bigint committed Nov 7, 2024
1 parent aba9f8d commit ba1dd5b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ runs:
env:
INPUT_SLUG_MAXLENGTH: ${{ inputs.slug-maxlength }}
INPUT_SHORT_LENGTH: ${{ inputs.short-length }}
outputs:
warnings: ${{ steps.prefligth.outputs.warnings }}

# From Environment Variables
- uses: rlespinasse/[email protected]
Expand Down Expand Up @@ -118,3 +120,7 @@ runs:
short-on-error: true
length: ${{ steps.prefligth.outputs.PREFLIGHT_SHORT_LENGTH }}
prefix: ${{ inputs.prefix }}

# Print warnings captured from preflight.sh
- name: Print warnings
run: echo "${{ steps.prefligth.outputs.warnings }}"
9 changes: 9 additions & 0 deletions preflight.sh
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ if [ -f "$GITHUB_OUTPUT" ]; then
else
echo "::set-output name=PREFLIGHT_SHORT_LENGTH::${PREFLIGHT_SHORT_LENGTH}"
fi

# Check for existing GITHUB_* variables using the env command
existing_github_vars=$(env | grep '^GITHUB_')

# Print a warning if any existing GITHUB_* variables are found
if [ -n "$existing_github_vars" ]; then
echo "::warning ::The following GITHUB_* variables already exist and may be overwritten:"
echo "$existing_github_vars"
fi

0 comments on commit ba1dd5b

Please sign in to comment.