Skip to content

Commit fe250d7

Browse files
SONARJAVA-5551 Create GitHub action to update rule metadata. (#5139)
1 parent b2d7a8b commit fe250d7

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Update Rule Metadata
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
RULE_API_VERSION: 2.10.0.4287
7+
PR_BRANCH_NAME: gh-action/update-rule-metadata
8+
9+
jobs:
10+
UpdateRuleMetadata_job:
11+
name: Update Rule Metadata
12+
runs-on: ubuntu-latest
13+
permissions:
14+
pull-requests: write
15+
contents: write
16+
id-token: write
17+
18+
steps:
19+
20+
- name: Checkout Sources
21+
uses: actions/checkout@v4
22+
23+
- name: Setup JFrog
24+
uses: SonarSource/jfrog-setup-wrapper@v3
25+
with:
26+
artifactoryRoleSuffix: private-reader
27+
28+
- name: Setup Rule API
29+
run: |
30+
jfrog rt download "sonarsource-private-releases/com/sonarsource/rule-api/rule-api/${{ env.RULE_API_VERSION }}/rule-api-${{ env.RULE_API_VERSION }}.jar" --flat
31+
working-directory: /tmp
32+
33+
- name: Setup Java
34+
uses: actions/setup-java@v4
35+
with:
36+
distribution: 'temurin'
37+
java-version: '21'
38+
39+
- name: Update Files
40+
run: |
41+
java -jar "/tmp/rule-api-${{ env.RULE_API_VERSION }}.jar" update
42+
sed --in-place='' -e 's/rule:java:S3649/rule:javasecurity:S3649/g' 'sonar-java-plugin/src/main/resources/org/sonar/l10n/java/rules/java/S2077.html'
43+
44+
- name: Create PR
45+
env:
46+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
git config user.name "${GITHUB_ACTOR}"
49+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
50+
git checkout -b "${{ env.PR_BRANCH_NAME }}"
51+
git commit -m 'Update rule metadata' -a
52+
git push --set-upstream origin "${{ env.PR_BRANCH_NAME }}"
53+
gh pr create -B master --title 'Update rule metadata' --body ''

0 commit comments

Comments
 (0)