Skip to content

Commit 9eea781

Browse files
BYKhubertdeng123
andauthored
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 <[email protected]>
1 parent 95761f7 commit 9eea781

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

Diff for: action.yaml

+14-4
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,22 @@ inputs:
1313
runs:
1414
using: "composite"
1515
steps:
16-
- name: Configure to use the test image
17-
if: inputs.project_name && inputs.image_url
16+
- name: Validate inputs and configure test image
1817
shell: bash
18+
env:
19+
PROJECT_NAME: ${{ inputs.project_name }}
20+
IMAGE_URL: ${{ inputs.image_url }}
1921
run: |
20-
image_var=$(echo ${{ inputs.project_name }}_IMAGE | tr '[:lower:]' '[:upper:]')
21-
echo "${image_var}=${{ inputs.image_url }}" >> ${{ github.action_path }}/.env
22+
if [[ -n "$PROJECT_NAME" && -n "$IMAGE_URL" ]]; then
23+
image_var=$(echo "${PROJECT_NAME}_IMAGE" | tr '[:lower:]' '[:upper:]')
24+
echo "${image_var}=$IMAGE_URL" >> ${{ github.action_path }}/.env
25+
elif [[ -z "$PROJECT_NAME" && -z "$IMAGE_URL" ]]; then
26+
echo "No project name and image URL set. Skipping image configuration."
27+
else
28+
echo "You must set both project_name and image_url or unset both."
29+
echo "project_name: $PROJECT_NAME, image_url: $IMAGE_URL"
30+
exit 1
31+
fi
2232
2333
- name: Setup dev environment
2434
shell: bash

0 commit comments

Comments
 (0)