-
Notifications
You must be signed in to change notification settings - Fork 2
Add nightly CodeQL CLI update workflow #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
783315c
Add nightly CodeQL CLI update workflow
data-douser e5f8b19
Update update-codeql.yml
data-douser 4b5a2fb
Merge branch 'main' into dd/test-release-workflow/2
data-douser fc260c1
Update .github/workflows/update-codeql.yml
data-douser 8edf080
Add validation for empty latest_tag in CodeQL update workflow (#60)
Copilot f4c8e6e
Apply suggestion from @data-douser
data-douser File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,159 @@ | ||
| name: Update CodeQL CLI Dependencies | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| # Nightly check for new CodeQL CLI releases | ||
| schedule: | ||
| - cron: '30 5 * * *' | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| # ───────────────────────────────────────────────────────────────────────────── | ||
| # Step 1: Detect new CodeQL CLI version | ||
| # | ||
| # Compares the current CodeQL CLI version in .codeql-version against the | ||
| # latest release from github/codeql-cli-binaries. If a newer version is | ||
| # available, downstream jobs orchestrate the update and PR creation. | ||
| # ───────────────────────────────────────────────────────────────────────────── | ||
| detect-update: | ||
| name: Detect CodeQL CLI Update | ||
| runs-on: ubuntu-latest | ||
|
|
||
| outputs: | ||
| current_version: ${{ steps.check-version.outputs.current_version }} | ||
| latest_version: ${{ steps.check-version.outputs.latest_version }} | ||
| update_needed: ${{ steps.check-version.outputs.update_needed }} | ||
| version: ${{ steps.check-version.outputs.version }} | ||
|
|
||
| steps: | ||
| - name: Detect - Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Detect - Check latest CodeQL CLI version | ||
| id: check-version | ||
| env: | ||
| GH_TOKEN: ${{ github.token }} | ||
| run: | | ||
| echo "Checking latest CodeQL CLI version..." | ||
|
|
||
| # Read current version from .codeql-version (stores vX.Y.Z) | ||
| current_version_raw=$(cat .codeql-version | tr -d '[:space:]') | ||
| current_version="${current_version_raw#v}" | ||
|
|
||
| # Get latest release from codeql-cli-binaries | ||
| latest_tag=$(gh release list --repo github/codeql-cli-binaries --json 'tagName,isLatest' --jq '.[] | select(.isLatest == true) | .tagName') | ||
| latest_clean="${latest_tag#v}" | ||
|
|
||
|
data-douser marked this conversation as resolved.
|
||
| echo "Current CodeQL CLI version: ${current_version}" | ||
| echo "Latest CodeQL CLI version: ${latest_clean}" | ||
|
|
||
|
data-douser marked this conversation as resolved.
|
||
| if [ "${latest_clean}" != "${current_version}" ]; then | ||
| echo "✅ Update available: ${current_version} → ${latest_clean}" | ||
| echo "update_needed=true" >> $GITHUB_OUTPUT | ||
| echo "current_version=${current_version}" >> $GITHUB_OUTPUT | ||
| echo "latest_version=${latest_clean}" >> $GITHUB_OUTPUT | ||
| echo "version=v${latest_clean}" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "ℹ️ CodeQL CLI is already up-to-date at version ${current_version}" | ||
| echo "update_needed=false" >> $GITHUB_OUTPUT | ||
| fi | ||
|
|
||
| - name: Detect - Summary | ||
| run: | | ||
| echo "## CodeQL CLI Update Check" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| if [ "${{ steps.check-version.outputs.update_needed }}" == "true" ]; then | ||
| echo "✅ Update available: ${{ steps.check-version.outputs.current_version }} → ${{ steps.check-version.outputs.latest_version }}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Initiating update pipeline for \`${{ steps.check-version.outputs.version }}\`..." >> $GITHUB_STEP_SUMMARY | ||
| else | ||
| echo "ℹ️ CodeQL CLI is already up-to-date. No changes needed." >> $GITHUB_STEP_SUMMARY | ||
| fi | ||
|
|
||
| # ───────────────────────────────────────────────────────────────────────────── | ||
| # Step 2: Update version, build, test, and create PR | ||
| # | ||
| # Updates all version-bearing files, installs dependencies, runs the full | ||
| # build-and-test suite, and creates a pull request with the changes. | ||
| # ───────────────────────────────────────────────────────────────────────────── | ||
| create-pr: | ||
| name: Create Update Pull Request | ||
| needs: detect-update | ||
| if: needs.detect-update.outputs.update_needed == 'true' | ||
| runs-on: ubuntu-latest | ||
|
|
||
| permissions: | ||
| contents: write | ||
| pull-requests: write | ||
|
|
||
| steps: | ||
| - name: Update - Checkout repository | ||
| uses: actions/checkout@v6 | ||
|
|
||
| - name: Update - Update .codeql-version | ||
| run: | | ||
| printf "v%s\n" "${{ needs.detect-update.outputs.latest_version }}" > .codeql-version | ||
| echo "Updated .codeql-version to ${{ needs.detect-update.outputs.version }}" | ||
|
|
||
| - name: Update - Setup CodeQL environment | ||
| uses: ./.github/actions/setup-codeql-environment | ||
| with: | ||
| add-to-path: true | ||
| install-language-runtimes: false | ||
|
|
||
| - name: Update - Setup Node.js | ||
| uses: actions/setup-node@v6 | ||
| with: | ||
| cache: 'npm' | ||
| node-version-file: '.node-version' | ||
|
|
||
| - name: Update - Update version in all files | ||
| run: | | ||
| LATEST="${{ needs.detect-update.outputs.latest_version }}" | ||
| echo "Updating all version-bearing files to ${LATEST}..." | ||
| ./server/scripts/update-release-version.sh --skip-cli-validation "${LATEST}" | ||
|
data-douser marked this conversation as resolved.
Outdated
|
||
|
|
||
| - name: Update - Install dependencies | ||
| run: npm install --include=optional | ||
|
|
||
| - name: Update - Install CodeQL pack dependencies | ||
| run: server/scripts/install-packs.sh | ||
|
|
||
| - name: Update - Build and test | ||
| run: npm run build-and-test | ||
|
|
||
| - name: Update - Create Pull Request | ||
| uses: peter-evans/create-pull-request@v8 | ||
|
data-douser marked this conversation as resolved.
Outdated
|
||
| with: | ||
| title: 'Upgrade CodeQL CLI dependency to ${{ needs.detect-update.outputs.version }}' | ||
| body: | | ||
| This PR upgrades the CodeQL CLI version to ${{ needs.detect-update.outputs.version }}. | ||
|
|
||
| **Changes made:** | ||
| - Updated `.codeql-version` to `${{ needs.detect-update.outputs.version }}` | ||
| - Updated all version-bearing files (package.json, codeql-pack.yml) to `${{ needs.detect-update.outputs.latest_version }}` | ||
| - Regenerated `package-lock.json` | ||
| - Installed CodeQL pack dependencies | ||
| - Build and tests passed ✅ | ||
| commit-message: 'Upgrade CodeQL CLI dependency to ${{ needs.detect-update.outputs.version }}' | ||
| delete-branch: true | ||
| branch: 'codeql/upgrade-to-${{ needs.detect-update.outputs.version }}' | ||
|
|
||
| - name: Update - Summary | ||
| run: | | ||
| VERSION="${{ needs.detect-update.outputs.version }}" | ||
| CURRENT="${{ needs.detect-update.outputs.current_version }}" | ||
| LATEST="${{ needs.detect-update.outputs.latest_version }}" | ||
| echo "## CodeQL CLI Update Summary" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "Triggered by CodeQL CLI update: ${CURRENT} → ${LATEST}" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "| Property | Old Value | New Value |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| -------- | --------- | --------- |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| .codeql-version | v${CURRENT} | ${VERSION} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| package.json versions | ${CURRENT} | ${LATEST} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "| codeql-pack.yml versions | ${CURRENT} | ${LATEST} |" >> $GITHUB_STEP_SUMMARY | ||
| echo "" >> $GITHUB_STEP_SUMMARY | ||
| echo "A pull request has been created with these changes." >> $GITHUB_STEP_SUMMARY | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.