Skip to content

Commit df9d4e1

Browse files
GHA-146 Add rspec-branch input to update-rule-metadata action (#63)
1 parent 673b8ae commit df9d4e1

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

update-rule-metadata/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ This action depends on:
2626
| `rule-api-version` | Version of the rule-api tooling to be used for the workflow. | No | `2.15.0.4476` |
2727
| `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 |
2828
| `branch` | Branch to run the check against and create the PR for. By default, it will use master. | No | `master` |
29+
| `rspec-branch` | Branch of the rspec repository to be used. If not specified, the `master` branch will be used by default. | No | `master` |
2930

3031
## Outputs
3132

@@ -97,6 +98,7 @@ jobs:
9798
rule-api-version: '2.16.0.5000'
9899
sonarpedia-files: 'frontend/java/sonarpedia.json,frontend/csharp/sonarpedia.json'
99100
branch: 'develop'
101+
rspec-branch: 'feature/my-rspec-branch'
100102
```
101103
102104
## Implementation Details

update-rule-metadata/action.yml

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@ inputs:
1414
description: |
1515
Branch to run the check against and create the PR for.
1616
default: master
17+
rspec-branch:
18+
description: |
19+
Branch of the rspec repository to be used.
20+
If not specified, the 'master' branch of the rspec repository will be used.
21+
default: master
1722

1823
outputs:
1924
has-changes:
@@ -133,8 +138,16 @@ runs:
133138
# Calculate relative path to rule-api.jar from current directory
134139
rel_path=$(realpath --relative-to="$PWD" "$original_dir/rule-api.jar")
135140
136-
# Run rule-api update in the current directory
137-
java -jar "$rel_path" update 2>&1 | tee -a $log_file
141+
from_branch="${{ inputs.rspec-branch }}"
142+
143+
# Run rule-api generate if rspec-branch is set and not master, else run update
144+
if [[ "$from_branch" != "" && "$from_branch" != "master" ]]; then
145+
echo "Running rule-api generate from branch '$from_branch'" >> $log_file
146+
java -jar "$rel_path" generate -branch "$from_branch" 2>&1 | tee -a $log_file
147+
else
148+
echo "Running rule-api update" >> $log_file
149+
java -jar "$rel_path" update 2>&1 | tee -a $log_file
150+
fi
138151
139152
# Return to the original directory
140153
cd "$original_dir"

0 commit comments

Comments
 (0)