Skip to content
Merged
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
2 changes: 2 additions & 0 deletions update-rule-metadata/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ This action depends on:
| `rule-api-version` | Version of the rule-api tooling to be used for the workflow. | No | `2.15.0.4476` |
| `sonarpedia-files` | Comma-separated list of sonarpedia files to be updated. By default, it will update all Sonarpedia files in the repository. | No | Auto-discovered |
| `branch` | Branch to run the check against and create the PR for. By default, it will use master. | No | `master` |
| `rspec-branch` | Branch of the rspec repository to be used. If not specified, the `master` branch will be used by default. | No | `master` |

## Outputs

Expand Down Expand Up @@ -97,6 +98,7 @@ jobs:
rule-api-version: '2.16.0.5000'
sonarpedia-files: 'frontend/java/sonarpedia.json,frontend/csharp/sonarpedia.json'
branch: 'develop'
rspec-branch: 'feature/my-rspec-branch'
```

## Implementation Details
Expand Down
17 changes: 15 additions & 2 deletions update-rule-metadata/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ inputs:
description: |
Branch to run the check against and create the PR for.
default: master
rspec-branch:
description: |
Branch of the rspec repository to be used.
If not specified, the 'master' branch of the rspec repository will be used.
default: master

outputs:
has-changes:
Expand Down Expand Up @@ -133,8 +138,16 @@ runs:
# Calculate relative path to rule-api.jar from current directory
rel_path=$(realpath --relative-to="$PWD" "$original_dir/rule-api.jar")

# Run rule-api update in the current directory
java -jar "$rel_path" update 2>&1 | tee -a $log_file
from_branch="${{ inputs.rspec-branch }}"

# Run rule-api generate if rspec-branch is set and not master, else run update
if [[ "$from_branch" != "" && "$from_branch" != "master" ]]; then
echo "Running rule-api generate from branch '$from_branch'" >> $log_file
java -jar "$rel_path" generate -branch "$from_branch" 2>&1 | tee -a $log_file
else
echo "Running rule-api update" >> $log_file
java -jar "$rel_path" update 2>&1 | tee -a $log_file
fi

# Return to the original directory
cd "$original_dir"
Expand Down
Loading