@@ -36,21 +36,37 @@ jobs:
3636 git-user-signingkey : true
3737 git-commit-gpgsign : true
3838
39+ - name : Fetch local scanner version
40+ uses : mikefarah/yq@v4.4.1
41+ with :
42+ cmd : echo local=$(yq e .appVersion scanners/${{ matrix.scanner }}/Chart.yaml) >> $GITHUB_ENV
43+
3944 - name : Fetch scanner's version API
4045 uses : mikefarah/yq@v4.4.1
4146 with :
4247 cmd : echo versionApi=$(yq e .annotations.versionApi scanners/${{ matrix.scanner }}/Chart.yaml) >> $GITHUB_ENV
4348
4449 - name : Fetch latest release scanner version
45- run : echo release=$((curl -sL ${{env.versionApi}} ) | jq -r ".tag_name") | tr -d "v" >> $GITHUB_ENV
46-
47- - name : Fetch local scanner version
48- uses : mikefarah/yq@v4.4.1
49- with :
50- cmd : echo local=$(yq e .appVersion scanners/${{ matrix.scanner }}/Chart.yaml) | tr -d "v" >> $GITHUB_ENV
50+ # A hacky way to solve the problem where the docker image is in the "1.0" format and the github release is in the "v1.0" format
51+ # We make sure to add or remove the "v" character when necessary
52+ run : |
53+ local=${{env.local}}
54+ release=$(curl -sL ${{env.versionApi}} | jq -r ".tag_name" )
55+ upgrade=$release
56+
57+ if [[ ${local:0:1} != ${release:0:1} ]] ; then
58+ if [[ ${local:0:1} == "v" ]] ; then
59+ upgrade=v${release};
60+ elif [[ ${release:0:1} == "v" ]] ; then
61+ upgrade=$(echo $release| tr -d "v")
62+ fi
63+ fi
64+
65+ echo $upgrade
66+ echo release=$upgrade >> $GITHUB_ENV
5167
5268 - name : Check if scanner is outdated and if PR already exists
53- if : ${{ env.release != env.local }}
69+ if : ${{ env.release != env.local && env.release != null }}
5470 run : |
5571 echo 'The ${{ matrix.scanner }} scanner is outdated. Current SCB version is ${{env.local}} and remote version is ${{env.release}}'
5672
@@ -61,15 +77,15 @@ jobs:
6177 echo prExists=$(gh pr list --state open --limit 100 | grep -F "$pullRequestTitle" -c) >> $GITHUB_ENV
6278
6379 - name : Fetch new release changelog
64- if : ${{ env.release != env.local }}
80+ if : ${{ env.release != env.local && env.release != null }}
6581 run : echo releaseChangelog=$((curl -sL ${{env.versionApi}} ) | jq -r ".body") >> $GITHUB_ENV
6682
6783 - name : Upgrade Scanner Helm Chart
68- if : ${{ env.release != env.local && env.prExists == 0 }}
84+ if : ${{ env.release != env.local && env.prExists == 0 && env.release != null }}
6985 uses : mikefarah/yq@v4.4.1
7086 with :
7187 # appVersion value in chart is replaced with release value. Empty lines are deleted in the process
72- cmd : yq e --inplace '.appVersion = "v ${{env.release}}"' ./scanners/${{ matrix.scanner }}/Chart.yaml
88+ cmd : yq e --inplace '.appVersion = "${{env.release}}"' ./scanners/${{ matrix.scanner }}/Chart.yaml
7389
7490 # Updating Helm Docs
7591 - name : Download Helm Docs
@@ -111,7 +127,7 @@ jobs:
111127 rm -rf helm-docs
112128
113129 - name : Create Pull Request
114- if : ${{ env.release != env.local && env.prExists == 0 }}
130+ if : ${{ env.release != env.local && env.prExists == 0 && env.release != null }}
115131 uses : peter-evans/create-pull-request@v3
116132 with :
117133 token : ${{ secrets.SCB_BOT_USER_TOKEN }}
0 commit comments