From 9eea781e1c189ebc2f2f757efa98b82f80fb7496 Mon Sep 17 00:00:00 2001 From: Burak Yigit Kaya Date: Sat, 25 Jan 2025 16:53:50 +0000 Subject: [PATCH] feat: Require both inputs to be set on action (#3554) Came as a feature request from @untitaker and I think it makes a lot of sense --------- Co-authored-by: Hubert Deng --- action.yaml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/action.yaml b/action.yaml index 3bdf597bf3..ebc22f4831 100644 --- a/action.yaml +++ b/action.yaml @@ -13,12 +13,22 @@ inputs: runs: using: "composite" steps: - - name: Configure to use the test image - if: inputs.project_name && inputs.image_url + - name: Validate inputs and configure test image shell: bash + env: + PROJECT_NAME: ${{ inputs.project_name }} + IMAGE_URL: ${{ inputs.image_url }} run: | - image_var=$(echo ${{ inputs.project_name }}_IMAGE | tr '[:lower:]' '[:upper:]') - echo "${image_var}=${{ inputs.image_url }}" >> ${{ github.action_path }}/.env + if [[ -n "$PROJECT_NAME" && -n "$IMAGE_URL" ]]; then + image_var=$(echo "${PROJECT_NAME}_IMAGE" | tr '[:lower:]' '[:upper:]') + echo "${image_var}=$IMAGE_URL" >> ${{ github.action_path }}/.env + elif [[ -z "$PROJECT_NAME" && -z "$IMAGE_URL" ]]; then + echo "No project name and image URL set. Skipping image configuration." + else + echo "You must set both project_name and image_url or unset both." + echo "project_name: $PROJECT_NAME, image_url: $IMAGE_URL" + exit 1 + fi - name: Setup dev environment shell: bash