@@ -106,21 +106,23 @@ runs:
106106 shell : bash
107107 env :
108108 GITHUB_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
109+ INPUT_SONARPEDIA_FILES : ${{ inputs.sonarpedia-files }}
110+ INPUT_RSPEC_BRANCH : ${{ inputs.rspec-branch }}
109111 run : |
110112 echo "" > rule-api-logs.txt
111-
113+
112114 # Check if specific sonarpedia-files input is provided
113- if [ -n "${{ inputs.sonarpedia-files}} " ]; then
114- echo "Using specified sonarpedia files: ${{ inputs.sonarpedia-files}} "
115-
115+ if [ -n "$INPUT_SONARPEDIA_FILES " ]; then
116+ echo "Using specified sonarpedia files: $INPUT_SONARPEDIA_FILES "
117+
116118 # Convert comma-separated list to array and process each file
117- IFS=',' read -ra SONARPEDIA_FILES <<< "${{ inputs.sonarpedia-files}} "
119+ IFS=',' read -ra SONARPEDIA_FILES <<< "$INPUT_SONARPEDIA_FILES "
118120 sonarpedia_dirs=""
119-
121+
120122 for file in "${SONARPEDIA_FILES[@]}"; do
121123 # Trim whitespace
122124 file=$(echo "$file" | xargs)
123-
125+
124126 # Check if file exists
125127 if [ -f "$file" ]; then
126128 # Get directory containing the file
@@ -130,43 +132,43 @@ runs:
130132 echo "Warning: Specified sonarpedia file not found: $file"
131133 fi
132134 done
133-
135+
134136 # Remove empty lines and duplicates
135137 sonarpedia_dirs=$(echo "$sonarpedia_dirs" | grep -v '^$' | sort | uniq)
136138 else
137139 echo "No specific files provided, discovering all sonarpedia.json files in repository"
138-
140+
139141 # Find all directories containing sonarpedia.json files
140142 sonarpedia_dirs=$(find . -name "sonarpedia.json" -type f | sed 's|/sonarpedia.json$||' | sort | uniq)
141143 fi
142-
144+
143145 if [ -z "$sonarpedia_dirs" ]; then
144146 echo "No sonarpedia.json files found to process"
145147 exit 1
146148 fi
147-
149+
148150 echo "Found sonarpedia.json files in the following directories:"
149151 echo "$sonarpedia_dirs"
150152 echo ""
151-
153+
152154 # Store the original directory
153155 original_dir=$(pwd)
154-
156+
155157 log_file="$original_dir/rule-api-logs.txt"
156-
158+
157159 # Loop through each directory containing sonarpedia.json
158160 while IFS= read -r dir; do
159161 if [ -d "$dir" ]; then
160162 echo "Processing directory: $dir"
161163 cd "$dir"
162-
164+
163165 echo "=== PATH:$dir ===" >> $log_file
164-
166+
165167 # Calculate relative path to rule-api.jar from current directory
166168 rel_path=$(realpath --relative-to="$PWD" "$original_dir/rule-api.jar")
167-
168- from_branch="${{ inputs.rspec-branch }} "
169-
169+
170+ from_branch="$INPUT_RSPEC_BRANCH "
171+
170172 # Run rule-api generate if rspec-branch is set and not master, else run update
171173 if [[ "$from_branch" != "" && "$from_branch" != "master" ]]; then
172174 echo "Running rule-api generate from branch '$from_branch'" >> $log_file
@@ -175,18 +177,19 @@ runs:
175177 echo "Running rule-api update" >> $log_file
176178 java -jar "$rel_path" update 2>&1 | tee -a $log_file
177179 fi
178-
180+
179181 # Return to the original directory
180182 cd "$original_dir"
181183 fi
182184 done <<< "$sonarpedia_dirs"
183185
184186 - name : Run Post Update Script
185- if : ${{ inputs.post-update }}
187+ if : ${{ inputs.post-update != '' }}
186188 shell : bash
187189 env :
188190 GITHUB_TOKEN : ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN }}
189- run : ${{ inputs.post-update }}
191+ INPUT_POST_UPDATE : ${{ inputs.post-update }}
192+ run : eval "$INPUT_POST_UPDATE"
190193
191194 - name : Remove rule-api jar
192195 shell : bash
@@ -239,7 +242,7 @@ runs:
239242 labels : ${{ inputs.labels }}
240243
241244 - name : Notify Slack
242- if : ${{ inputs.slack-channel != '' && steps.create-pr.outputs.pull-request-operation != 'none' }}
245+ if : ${{ inputs.slack-channel != '' && ( steps.create-pr.outputs.pull-request-operation == 'created' || steps.create-pr.outputs.pull-request-operation == 'updated') }}
243246 uses : SonarSource/release-github-actions/notify-slack@v1
244247 with :
245248 project-name : ${{ github.repository }}
0 commit comments