Skip to content

Commit 2a9251f

Browse files
authored
chore: fix sonarcloud issues (#1836)
* chore: fix sonarcloud issues Signed-off-by: Kim Tsao <ktsao@redhat.com> * chore: replace inline scripts with env var usage Signed-off-by: Kim Tsao <ktsao@redhat.com> --------- Signed-off-by: Kim Tsao <ktsao@redhat.com>
1 parent d05ec94 commit 2a9251f

1 file changed

Lines changed: 21 additions & 10 deletions

File tree

.github/workflows/release_workspace_version.yml

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,16 @@ jobs:
2525
steps:
2626
- name: Check PR title, author, branch and merged status
2727
id: check_pr
28+
env:
29+
PR_TITLE: ${{ github.event.pull_request.title }}
30+
HEAD_REF: ${{ github.event.pull_request.head.ref }}
31+
USER_LOGIN: ${{ github.event.pull_request.user.login }}
32+
PR_MERGED: ${{ github.event.pull_request.merged }}
2833
run: |
29-
if [[ "${{ github.event.pull_request.title }}" == Version*Packages* \
30-
&& "${{ github.event.pull_request.user.login }}" == "rhdh-bot" ]] \
31-
&& [[ "${{ github.event.pull_request.head.ref }}" == maintenance-changesets-release/* ]] \
32-
&& [[ "${{ github.event.pull_request.merged }}" == "true" ]]; then
34+
if [[ "$PR_TITLE" == Version*Packages* \
35+
&& "$USER_LOGIN" == "rhdh-bot" ]] \
36+
&& [[ "$HEAD_REF" == maintenance-changesets-release/* ]] \
37+
&& [[ "PR_MERGED" == "true" ]]; then
3338
echo "is_version_pr=true" >> $GITHUB_OUTPUT
3439
else
3540
echo "is_version_pr=false" >> $GITHUB_OUTPUT
@@ -38,8 +43,10 @@ jobs:
3843
# ADDED: Extracts workspace name from branch, ensuring it is a workspace/** branch
3944
- name: Extract Workspace name from branch
4045
id: extract_workspace
46+
env:
47+
BASE_REF: ${{ github.event.pull_request.base.ref }}
4148
run: |
42-
WORKSPACE_NAME=$(echo "${{ github.event.pull_request.base.ref }}" | cut -d'/' -f2)
49+
WORKSPACE_NAME=$(echo "$BASE_REF" | cut -d'/' -f2)
4350
echo "workspace_name=$WORKSPACE_NAME" >> $GITHUB_OUTPUT
4451
4552
changesets-pr:
@@ -62,9 +69,11 @@ jobs:
6269
ref: ${{ github.ref }}
6370

6471
- name: Verify maintenance-changesets-release branch does not exist
72+
env:
73+
WORKSPACE_NAME: ${{ needs.check-merged-pr.outputs.workspace_name }}
6574
run: |
66-
if git ls-remote --exit-code origin "refs/heads/maintenance-changesets-release/${{ needs.check-merged-pr.outputs.workspace_name }}"; then
67-
echo "Error: maintenance-changesets-release/${{ needs.check-merged-pr.outputs.workspace_name }} branch already exists. Please clean up the branch before proceeding."
75+
if git ls-remote --exit-code origin "refs/heads/maintenance-changesets-release/$WORKSPACE_NAME"; then
76+
echo "Error: maintenance-changesets-release/$WORKSPACE_NAME branch already exists. Please clean up the branch before proceeding."
6877
exit 1
6978
fi
7079
@@ -90,10 +99,12 @@ jobs:
9099
run: yarn install --immutable
91100

92101
- name: Fetch previous commit for release check
93-
run: git fetch origin '${{ github.event.pull_request.base.sha }}'
102+
env:
103+
BASE_SHA: ${{ github.event.pull_request.base.sha }}
104+
run: git fetch origin "$BASE_SHA"
94105

95106
- name: Fetch the commit that triggered the workflow (used by backstage/changesets-action)
96-
run: git fetch origin ${{ github.sha }}
107+
run: git fetch origin "$GITHUB_SHA"
97108
continue-on-error: true
98109

99110
- name: Check if release
@@ -170,7 +181,7 @@ jobs:
170181
# CHANGED: Publish with tag "maintenance" to avoid overwriting the latest npm tag
171182
- name: publish
172183
run: |
173-
yarn config set -H 'npmAuthToken' "${{secrets.RHDH_NPM_TOKEN}}"
184+
yarn config set -H 'npmAuthToken' "$NODE_AUTH_TOKEN"
174185
yarn workspaces foreach -v --no-private npm publish --access public --tolerate-republish --tag "maintenance"
175186
env:
176187
NODE_AUTH_TOKEN: ${{ secrets.RHDH_NPM_TOKEN }}

0 commit comments

Comments
 (0)