Skip to content

Updated CI with pull push options #5

Updated CI with pull push options

Updated CI with pull push options #5

Workflow file for this run

name: CI
on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master
env: # configure environment variables for git commits
actor: "41898282+github-actions[bot]"
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code for push
      if: github.event_name == 'push'
      uses: actions/checkout@v3
      with:
        fetch-depth: 0
        ref: ${{ github.ref_name }}
    - name: Checkout code for pull request
      if: github.event_name == 'pull_request'
      uses: actions/checkout@v3
      with:
        fetch-depth: 0
        ref: ${{ github.head_ref }}
- name: Set up Python 3.11

Check failure on line 32 in .github/workflows/ci.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/ci.yml

Invalid workflow file

You have an error in your yaml syntax on line 32
uses: actions/setup-python@v3
with:
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest black flake8 # also install black & flake8
if [ -f requirements.txt ]; then
pip install -r requirements.txt
fi
- name: Configure git # use the environment variable we set above
run: |
git config --local user.email "${actor}@users.noreply.github.com"
git config --local user.name "$actor"
- name: Test
run: |
pytest .
- name: Format & lint
run: |
black . # first run black, then run flake8
flake8 --extend-ignore E203 --max-line-length 88 .
- name: Commit and push changes
run: |
git add .
git commit -m "🎨 Style code" || echo "No changes to commit"
git push origin HEAD:main