khulnasoft-lab/codeql-migrator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Automate the migration of CodeQL Action from v2 to v3 across repositories.

has deprecated CodeQL Action v2, and workflows using it may eventually break. This tool:

  • Finds repositories still using CodeQL v2.
  • Automatically updates workflows to CodeQL v3.
  • Creates pull requests to suggest upgrades.

โœ… Scans repositories for CodeQL v2 usage.
โœ… Updates workflow files to use CodeQL v3.
โœ… Creates pull requests with upgrade suggestions.
โœ… Works on public and private repositories.
โœ… Can be run manually or as a Action.

git clone https://.com/YOUR-USERNAME/codeql-migrator.git
cd codeql-migrator
python3 -m venv venv
source venv/bin/activate  # Windows: venv\Scripts\activate
pip install -r requirements.txt

Create a Personal Access Token (PAT) with repo and workflow permissions.
Set it as an environment variable:

export _TOKEN="your_personal_access_token"
python migrator.py

You can schedule automated runs with Actions.
Create ./workflows/run-migrator.yml:

name: Run CodeQL Migrator
on:
  schedule:
    - cron: '0 0 * * 1'  # Runs every Monday
  workflow_dis:  # Allows manual triggering
jobs:
  run-script:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout Repository
        uses: actions/checkout@v3

      - name: Setup Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.x'

      - name: Install Dependencies
        run: pip install requests pyyaml 3.py

      - name: Run Migration Script
        env:
          _TOKEN: ${{ secrets._TOKEN }}
        run: python migrator.py

Add this workflow to your repository to automatically migrate CodeQL from v2 to v3:

:/./workflows/codeql-migration.yml name: CodeQL Migration on: schedule: - cron: '0 0 * * 1' # Runs every Monday workflow_dis:

jobs: migrate: runs-on: ubuntu-latest permissions: contents: write pull-requests: write steps: - uses: khulnasoft-lab/codeql-migrator@v1 with: -token: ${{ secrets._TOKEN }}

InputDescriptionRequiredDefault
-tokentoken for authenticationYes-
per-pageNumber of repositories to processNo'10'
dry-runShow what would be done without making changesNo'false'
branch-nameName of the branch to create for changesNo'update-codeql-v3'
skip-cleanupSkip cleanup of cloned repositoriesNo'false'
max-workersNumber of concurrent workersNo'4'
log-levelLogging verbosityNo'INFO'
commit-messageCommit message for the changesNo'Update CodeQL action to v3'
pr-titleTitle for the pull requestNo'Update CodeQL action from v2 to v3'
pr-bodyBody text for the pull requestNo'This PR updates the CodeQL action from v2 to v3.'

1๏ธโƒฃ Finds repos using CodeQL v2 via API.
2๏ธโƒฃ Clones the repo and checks workflow files.
3๏ธโƒฃ Replaces uses: /codeql-action/*@v2 with @v3.
4๏ธโƒฃ Commits changes & creates a pull request.

  • The script does not store credentials.
  • Uses API rate-limits apply.
  • Verify pull requests before merging.
  • Add CLI options for manual repo input.
  • Improve logging and error handling.
  • Turn into a App for automatic suggestions.

PRs are welcome! Follow the standard workflow:

  1. Fork the repository.
  2. Create a feature branch (git checkout -b feature-name).
  3. Commit changes (git commit -m "Add new feature").
  4. Push to your branch (git push origin feature-name).
  5. Open a pull request.

Licensed under the MIT License.

If this project helps you, give it a โญ on !

The tool is available as a Docker image from Container Registry:

docker pull ghcr.io/khulnasoft-lab/codeql-migrator:latest

Run it with your token:

docker run -e _TOKEN="your_token" ghcr.io/khulnasoft-lab/codeql-migrator:latest

You can also use it with additional parameters:

docker run -e _TOKEN="your_token" ghcr.io/khulnasoft-lab/codeql-migrator:latest \
  --per-page 20 \
  --dry-run \
  --branch-name custom-branch

๐Ÿ”ฅ Automate your CodeQL upgrades today! ๐Ÿ”ฅ

About

๐Ÿš€ ๐˜ผ๐™ช๐™ฉ๐™ค๐™ข๐™–๐™ฉ๐™š ๐˜พ๐™ค๐™™๐™š๐™Œ๐™‡ ๐™ซ๐Ÿฎ โžœ ๐™ซ๐Ÿฏ ๐™ˆ๐™ž๐™œ๐™ง๐™–๐™ฉ๐™ž๐™ค๐™ฃ | ๐—จ๐—ฝ๐—ด๐—ฟ๐—ฎ๐—ฑ๐—ฒ ๐—š๐—ถ๐˜๐—›๐˜‚๐—ฏ ๐—”๐—ฐ๐˜๐—ถ๐—ผ๐—ป๐˜€ ๐—ช๐—ผ๐—ฟ๐—ธ๐—ณ๐—น๐—ผ๐˜„๐˜€ ๐—˜๐—ฎ๐˜€๐—ถ๐—น๐˜† ๐Ÿš€

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

 
 
 

Contributors 4

  •  
  •  
  •  
  •