@@ -37,21 +37,37 @@ jobs:
3737 git-user-signingkey : true
3838 git-commit-gpgsign : true
3939
40+ - name : Fetch local scanner version
41+ uses : mikefarah/yq@v4.4.1
42+ with :
43+ cmd : echo local=$(yq e .appVersion scanners/${{ matrix.scanner }}/Chart.yaml) >> $GITHUB_ENV
44+
4045 - name : Fetch scanner's version API
4146 uses : mikefarah/yq@v4.4.1
4247 with :
4348 cmd : echo versionApi=$(yq e .annotations.versionApi scanners/${{ matrix.scanner }}/Chart.yaml) >> $GITHUB_ENV
4449
4550 - name : Fetch latest release scanner version
46- run : echo release=$((curl -sL ${{env.versionApi}} ) | jq -r ".tag_name") | tr -d "v" >> $GITHUB_ENV
47-
48- - name : Fetch local scanner version
49- uses : mikefarah/yq@v4.4.1
50- with :
51- cmd : echo local=$(yq e .appVersion scanners/${{ matrix.scanner }}/Chart.yaml) | tr -d "v" >> $GITHUB_ENV
51+ # 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
52+ # We make sure to add or remove the "v" character when necessary
53+ run : |
54+ local=${{env.local}}
55+ release=$(curl -sL ${{env.versionApi}} | jq -r ".tag_name" )
56+ upgrade=$release
57+
58+ if [[ ${local:0:1} != ${release:0:1} ]] ; then
59+ if [[ ${local:0:1} == "v" ]] ; then
60+ upgrade=v${release};
61+ elif [[ ${release:0:1} == "v" ]] ; then
62+ upgrade=$(echo $release| tr -d "v")
63+ fi
64+ fi
65+
66+ echo $upgrade
67+ echo release=$upgrade >> $GITHUB_ENV
5268
5369 - name : Check if scanner is outdated and if PR already exists
54- if : ${{ env.release != env.local }}
70+ if : ${{ env.release != env.local && env.release != null }}
5571 run : |
5672 echo 'The ${{ matrix.scanner }} scanner is outdated. Current SCB version is ${{env.local}} and remote version is ${{env.release}}'
5773
@@ -65,14 +81,15 @@ jobs:
6581 if : ${{ env.release != env.local }}
6682 run : |
6783 changelog=$(curl -sL ${{env.versionApi}} | jq -r ".body" | sed -e 's/#[0-9]\+//g')
84+ echo $changelog
6885 echo releaseChangelog=$changelog >> $GITHUB_ENV
6986
7087 - name : Upgrade Scanner Helm Chart
71- if : ${{ env.release != env.local && env.prExists == 0 }}
88+ if : ${{ env.release != env.local && env.prExists == 0 && env.release != null }}
7289 uses : mikefarah/yq@v4.4.1
7390 with :
7491 # appVersion value in chart is replaced with release value. Empty lines are deleted in the process
75- cmd : yq e --inplace '.appVersion = "v ${{env.release}}"' ./scanners/${{ matrix.scanner }}/Chart.yaml
92+ cmd : yq e --inplace '.appVersion = "${{env.release}}"' ./scanners/${{ matrix.scanner }}/Chart.yaml
7693
7794 # Updating Helm Docs
7895 - name : Download Helm Docs
@@ -114,7 +131,7 @@ jobs:
114131 rm -rf helm-docs
115132
116133 - name : Create Pull Request
117- if : ${{ env.release != env.local && env.prExists == 0 }}
134+ if : ${{ env.release != env.local && env.prExists == 0 && env.release != null }}
118135 uses : peter-evans/create-pull-request@v3
119136 with :
120137 token : ${{ secrets.SCB_BOT_USER_TOKEN }}
0 commit comments