Update the Veracode CLI #6
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 the Veracode CLI | |
| on: | |
| schedule: | |
| - cron: '0 2 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update-veracode-cli: | |
| runs-on: ubuntu-latest | |
| continue-on-error: true | |
| permissions: | |
| contents: write | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - name: Update Veracode CLI to latest version | |
| run: | | |
| cd helper/cli | |
| cliFile=$(ls -1 . | head -n 1) | |
| echo "Filename: $cliFile" | |
| local_version="${cliFile#*_}" | |
| local_version="${local_version%%_*}" | |
| echo "Local version: $local_version" | |
| curl -sSO https://tools.veracode.com/veracode-cli/LATEST_VERSION | |
| latest_version=$(<"LATEST_VERSION") | |
| echo "Latest version: $latest_version" | |
| if [[ "$local_version" == "$latest_version" ]]; then | |
| echo "We already have the latest version - nothing to do here" | |
| rm -rf LATEST_VERSION | |
| else | |
| echo "There is a new version we need to downlaod" | |
| downloadUrl="https://tools.veracode.com/veracode-cli/veracode-cli_${latest_version}_linux_x86.tar.gz" | |
| echo "Download URL: $downloadUrl" | |
| curl -sSO $downloadUrl | |
| curl -sS -o veracode-cli_${latest_version}_windows.ps1 https://tools.veracode.com/veracode-cli/install.ps1 | |
| ls -la | |
| echo "CLEAN UP" | |
| rm -rf veracode-cli_${local_version}_linux_x86.tar.gz | |
| rm -rf LATEST_VERSION | |
| ls -la | |
| fi | |
| - name: commit back to repo | |
| run: | | |
| git config --global user.name 'veracode' | |
| git config --global user.email 'cli@veracode.com' | |
| # Check if there are any changes | |
| if [[ -n "$(git status --porcelain)" ]]; then | |
| echo "Changes detected — committing and pushing latest CLI." | |
| git add -A | |
| git commit -m "New CLI Version" | |
| git push --verbose | |
| else | |
| echo "No changes to commit." | |
| fi |