Update Checkmarx AST CLI #5
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update Checkmarx AST CLI | |
on: | |
workflow_dispatch: | |
inputs: | |
new_cli_version: | |
description: 'New CLI version' | |
required: false | |
schedule: | |
- cron: '0 0 * * *' | |
jobs: | |
update-checkmarx-cli: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# Fetch the latest Checkmarx AST CLI version | |
- name: Get Latest Checkmarx API version | |
id: checkmarx-ast-cli | |
run: | | |
LATEST_VERSION=$(curl -sL https://api.github.com/repos/Checkmarx/ast-cli/releases/latest | jq -r ".tag_name") | |
CURRENT_VERSION=$(<checkmarx-ast-cli.version) | |
echo ::set-output name=release_tag::$LATEST_VERSION | |
echo ::set-output name=current_tag::$CURRENT_VERSION | |
# Update the version file if the latest version differs | |
- name: Update Checkmarx CLI version in version file | |
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag | |
env: | |
RELEASE_TAG: ${{ steps.checkmarx-ast-cli.outputs.release_tag }} | |
run: | | |
echo ${{ steps.checkmarx-ast-cli.outputs.release_tag }} > checkmarx-ast-cli.version | |
# Update the TypeScript file's cliDefaultVersion field | |
- name: Update cliDefaultVersion in CxInstaller.ts | |
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag | |
env: | |
NEW_CLI_VERSION: ${{ steps.checkmarx-ast-cli.outputs.release_tag }} | |
run: | | |
FILE_PATH="src/main/osinstaller/CxInstaller.ts" | |
# Update the cliDefaultVersion field in the TypeScript file | |
sed -i "s/\(private cliDefaultVersion = '\)[^']*\(';\)/\1${NEW_CLI_VERSION}\2/" $FILE_PATH | |
# Create a Pull Request with the version changes | |
- name: Create Pull Request | |
if: steps.checkmarx-ast-cli.outputs.current_tag != steps.checkmarx-ast-cli.outputs.release_tag | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} | |
commit-message: Update checkmarx-ast-cli to ${{ steps.checkmarx-ast-cli.outputs.release_tag }} | |
title: Update checkmarx-ast-cli binaries with ${{ steps.checkmarx-ast-cli.outputs.release_tag }} | |
body: | | |
Updates [checkmarx-ast-cli][1] to ${{ steps.checkmarx-ast-cli.outputs.release_tag }} | |
Auto-generated by [create-pull-request][2] | |
[1]: https://github.com/Checkmarx/checkmarx-ast-cli | |
labels: cxone | |
branch: feature/update_cli |