Merge pull request #63 from open-forest-observatory/dy_separate-camer… #5
This file contains 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: Code Formatter | |
# Add 'pull_request:' beneath 'on:' to apply on active PRs | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
isort: | |
name: Run Isort | |
runs-on: ubuntu-latest | |
# Redundant to determine branch name since workflow only runs on main, but will be useful if we also want the workflow to run PRs | |
steps: | |
- name: Determine Branch Name | |
run: | | |
if [ "${{ github.event_name }}" = "pull_request" ]; then | |
echo "BRANCH_NAME=${{ github.head_ref }}" >> $GITHUB_ENV | |
else | |
BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/}) | |
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV | |
fi | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ env.BRANCH_NAME }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Run Isort | |
run: pip install isort==5.13.2 && isort . | |
- name: Push changes | |
uses: stefanzweifel/git-auto-commit-action@v5 | |
with: | |
commit_message: Apply isort formatting changes | |
# Ensure Black runs after Isort has completed | |
black: | |
needs: isort | |
uses: ./.github/workflows/black.yml |