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

Print a warning if a GITHUB_* variable from this action already exists #151

Open
wants to merge 1 commit into
base: v5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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