Skip to content

cclauss/Upgrade-to-Python3

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

Upgrade to Python3

A GitHub Action that will upgrade your Python code to Python 3

This action uses flake8 to know if your Python code has syntax errors.

If syntax errors are found then this Action uses futurize create pull requests that gradually upgrade that code to be more compatible with Python 3. After this Action has run, return to your repo and look for a "modernize-Python-2-codes" branch in your repo. If this branch exists then select it and make pull request and make sure that your automate tests pass before merging the pull request. After merging, delete the "modernize-Python-2-codes" branch so that the process can be repeated.

Example workflow (Put the following text into your repo's .github/workflows/upgrade-to-py3.yml):

on:
  push:
    branches:
      - master

jobs:
  upgrade_to_Python3:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - name: "Upgrade to Python3"
        uses: cclauss/Upgrade-to-Python3@master
      - name: Commit files
        run: |
              git config --local user.email "me@me.me"
              git config --local user.name "GitHub Action"
              git commit -m "Add changes" -a
      - name: Push changes
        uses: peter-evans/create-pull-request@v2
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          branch: 'py3-addendum'