Skip to content

Commit e9e8b9c

Browse files
SONARXML-322 Create UpdateRuleMetadata.yml (#425)
1 parent e329761 commit e9e8b9c

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Update Rule Metadata
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
PR_BRANCH_NAME: "gh-action/update-rule-metadata.${{ github.run_id }}"
7+
8+
jobs:
9+
UpdateRuleMetadata_job:
10+
name: Update Rule Metadata
11+
runs-on: github-ubuntu-latest-s
12+
permissions:
13+
pull-requests: write
14+
contents: write
15+
id-token: write
16+
17+
steps:
18+
19+
- name: Checkout Sources
20+
uses: actions/checkout@v4
21+
22+
- name: Setup JFrog
23+
uses: SonarSource/jfrog-setup-wrapper@v3
24+
with:
25+
artifactoryRoleSuffix: private-reader
26+
27+
- name: Setup Rule API
28+
run: |
29+
jfrog rt curl -sLf "sonarsource-private-releases/com/sonarsource/rule-api/rule-api/%5BRELEASE%5D/rule-api-%5BRELEASE%5D.jar" -o rule-api.jar
30+
echo "Latest com.sonarsource.rule-api:rule-api release:"
31+
jar xf rule-api.jar META-INF/MANIFEST.MF
32+
grep 'Implementation-Version' META-INF/MANIFEST.MF
33+
working-directory: /tmp
34+
35+
- name: Setup Java
36+
uses: actions/setup-java@v4
37+
with:
38+
distribution: 'temurin'
39+
java-version: '21'
40+
41+
- name: Getting Vault Secrets
42+
id: secrets
43+
uses: SonarSource/vault-action-wrapper@320bd31b03e5dacaac6be51bbbb15adf7caccc32 # v3.1.0
44+
with:
45+
secrets: |
46+
development/github/token/{REPO_OWNER_NAME_DASH}-rspec token | GITHUB_TOKEN_RSPEC;
47+
48+
- name: Update Files
49+
env:
50+
GITHUB_TOKEN: ${{ fromJSON(steps.secrets.outputs.vault).GITHUB_TOKEN_RSPEC }}
51+
run: |
52+
java -jar "/tmp/rule-api.jar" update
53+
java -jar "/tmp/rule-api.jar" generate -rule XPathCheck
54+
cp sonar-xml-plugin/src/main/resources/org/sonar/l10n/xml/rules/xml/S140.html sonar-xml-plugin/src/main/resources/org/sonar/l10n/xml/rules/xml/XPathCheck.html
55+
cp sonar-xml-plugin/src/main/resources/org/sonar/l10n/xml/rules/xml/S140.json sonar-xml-plugin/src/main/resources/org/sonar/l10n/xml/rules/xml/XPathCheck.json
56+
57+
- name: Create PR
58+
id: create-pr
59+
env:
60+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
61+
run: |
62+
git config user.name "${GITHUB_ACTOR}"
63+
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
64+
git checkout -b "${{ env.PR_BRANCH_NAME }}"
65+
git commit -m 'Update rule metadata' -a
66+
git push --set-upstream origin "${{ env.PR_BRANCH_NAME }}"
67+
URL=$(gh pr create -B master --title 'Update rule metadata' --body '')
68+
echo "url=${URL}" >> $GITHUB_OUTPUT
69+
70+
- name: Summary
71+
run: |
72+
echo "Generated ${{steps.create-pr.outputs.url}}." >> $GITHUB_STEP_SUMMARY
73+
echo "Tip: close and reopen the PR to trigger CI. " >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)