11name : Update checkmarx ast cli
2+
23on :
34 workflow_dispatch :
5+ inputs :
6+ cli-tag :
7+ description : ' Optional CLI tag to upgrade to'
8+ required : false
49 repository_dispatch :
510 types : [cli-version-update]
611
@@ -23,51 +28,57 @@ jobs:
2328 git config --global user.name github-actions
2429 git config --global user.email github-actions@github.com
2530
26- - name : Get Latest Checkmarx API version
27- id : checkmarx-ast- cli
31+ - name : Determine target CLI version
32+ id : determine- cli-version
2833 run : |
29- echo ::set-output name=release_tag::$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
30- echo ::set-output name=current_tag::$(<checkmarx-ast-cli.version)
34+ if [ -n "${{ github.event.inputs.cli-tag }}" ]; then
35+ echo "Using user-provided CLI tag: ${{ github.event.inputs.cli-tag }}"
36+ echo "release_tag=${{ github.event.inputs.cli-tag }}" >> $GITHUB_OUTPUT
37+ else
38+ echo "Fetching latest release from GitHub..."
39+ LATEST_TAG=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name")
40+ echo "release_tag=$LATEST_TAG" >> $GITHUB_OUTPUT
41+ fi
42+ echo "current_tag=$(<checkmarx-ast-cli.version)" >> $GITHUB_OUTPUT
3143
32- - name : Update Checkmarx cli version
33- if : steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
34- env :
35- RELEASE_TAG : ${{ steps.checkmarx-ast-cli.outputs.release_tag }}
36- run : |
37- # Update current release
38- echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version
44+ - name : Update Checkmarx CLI version file
45+ if : steps.determine-cli-version.outputs.current_tag != steps.determine-cli-version.outputs.release_tag
46+ run : echo "${{ steps.determine-cli-version.outputs.release_tag }}" > checkmarx-ast-cli.version
3947
40- - name : Download latest cli and update branch
41- if : steps.checkmarx-ast- cli.outputs.current_tag != steps.checkmarx-ast- cli.outputs.release_tag
48+ - name : Download CLI and run update script
49+ if : steps.determine- cli-version .outputs.current_tag != steps.determine- cli-version .outputs.release_tag
4250 run : |
43- # Update binaries
4451 chmod +x ./.github/scripts/update_cli.sh
45- ./.github/scripts/update_cli.sh ${{ steps.checkmarx-ast- cli.outputs.release_tag }}
52+ ./.github/scripts/update_cli.sh ${{ steps.determine- cli-version .outputs.release_tag }}
4653
4754 - name : Track large files with Git LFS
48- if : steps.checkmarx-ast- cli.outputs.current_tag != steps.checkmarx-ast- cli.outputs.release_tag
55+ if : steps.determine- cli-version .outputs.current_tag != steps.determine- cli-version .outputs.release_tag
4956 run : |
5057 git lfs track "src/main/wrapper/resources/cx-linux"
5158 git lfs track "src/main/wrapper/resources/cx.exe"
5259 git lfs track "src/main/wrapper/resources/cx-mac"
5360 git add .gitattributes
5461 git add src/main/wrapper/resources/cx-linux src/main/wrapper/resources/cx.exe src/main/wrapper/resources/cx-mac
55- git commit -m "Track Checkmarx CLI binaries with Git LFS"
62+
63+ - name : Commit and push changes directly (no PR)
64+ if : github.event.inputs.cli-tag != ''
65+ run : |
66+ git add checkmarx-ast-cli.version
67+ git commit -m "Direct update of Checkmarx CLI to ${{ steps.determine-cli-version.outputs.release_tag }}"
68+ git push origin HEAD
5669
5770 - name : Create Pull Request
58- id : cretae_pull_request
59- if : steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag
60- uses : peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c # v6
71+ if : github.event.inputs.cli-tag == '' && steps.determine-cli-version.outputs.current_tag != steps.determine-cli-version.outputs.release_tag
72+ uses : peter-evans/create-pull-request@v6
6173 with :
6274 token : ${{ secrets.AUTOMATION_TOKEN }}
63- commit-message : Update checkmarx-ast-cli to ${{ steps.checkmarx-ast- cli.outputs.release_tag }}
64- title : Update checkmarx-ast-cli binaries with ${{ steps.checkmarx-ast- cli.outputs.release_tag }}
75+ commit-message : Update checkmarx-ast-cli to ${{ steps.determine- cli-version .outputs.release_tag }}
76+ title : Update checkmarx-ast-cli binaries with ${{ steps.determine- cli-version .outputs.release_tag }}
6577 body : |
66- Updates [checkmarx-ast-cli][1] to ${{ steps.checkmarx-ast- cli.outputs.release_tag }}
78+ Updates [checkmarx-ast-cli][1] to ${{ steps.determine- cli-version .outputs.release_tag }}
6779
6880 Auto-generated by [create-pull-request][2]
6981
7082 [1]: https://github.com/Checkmarx/checkmarx-ast-cli
7183 labels : cxone
72- branch : feature/update_cli_${{ steps.checkmarx-ast-cli.outputs.release_tag }}
73-
84+ branch : feature/update_cli_${{ steps.determine-cli-version.outputs.release_tag }}
0 commit comments